Linux环境下,java调用Https接口报错

Linux环境下,java调用Https接口报错,搜索了很多文章都没能解决,有没有大神指导指导,万分感谢! java.net.UnknownServiceException: Unable to find acceptable protocols. isFallback=false, modes=[ConnectionSpec(cipherSuites=[TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA], tlsVersions=[TLS_1_3, TLS_1_2, TLS_1_1, TLS_1_0], supportsTlsExtensions=true), ConnectionSpec()], supported protocols=[SSLv3]
at okhttp3.internal.connection.ConnectionSpecSelector.configureSecureSocket(ConnectionSpecSelector.java:70)
at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:274)
at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:251)
at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:151)
at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:192)
at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:121)
at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:100)
at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:185)
at okhttp3.RealCall.execute(RealCall.java:69)

UnknownServiceException: Unable to find acceptable protocols.
没有找到合适的协议。
1、本地测试是否正常
2、https请求是否需要ssl认证

本地测试正常,打到服务器就报至这个错了,现在不确定是jdk问题还是证书问题,需要ssl认证,目前jdk版本是1.6.0_24

是不是没有证书,先用openssl工具生成证书,然后把证书路径配置到java里面去
https://www.cnblogs.com/liuchd/p/15214212.html

更新最新版本的okhttp3

参考:
https://github.com/kubernetes-client/java/issues/655
https://github.com/square/okhttp/pull/3218

博主参考一下以下链接

java 访问 https网站_解决java访问https网站报错的问题_weixin_39876514的博客-CSDN博客 听说java的苛刻,没有想到居然到了如此严格的地步。因为抽取数据的需要,在jsp中需要对其他网站页面截取,今天发现怪异的问题,在windows的开发环境一切正常,但是部署到linux上就不能运行提示:javax.net.ssl.SSLException: java.security.ProviderException: java.security.InvalidKeyException: EC p... https://blog.csdn.net/weixin_39876514/article/details/114083137?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522166694833516782427431425%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=166694833516782427431425&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~rank_v31_ecpm-1-114083137-null-null.nonecase&utm_term=Linux%E7%8E%AF%E5%A2%83%E4%B8%8B%EF%BC%8Cjava%E8%B0%83%E7%94%A8Https%E6%8E%A5%E5%8F%A3%E6%8A%A5%E9%94%99&spm=1018.2226.3001.4450

linux java 程序https请求失败_changyus的博客-CSDN博客 报错信息javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: Certificates does not conform to algorithm constraints原因:  JDK7/8后添加了安全机制,导致这个问题出现解决方案:方案一:把$JAVA_HOME/jre/lib/security/java.security 文件里的jdk.certpath.disabledAl. https://blog.csdn.net/changyus/article/details/111322106?ops_request_misc=&request_id=&biz_id=102&utm_term=Linux%E7%8E%AF%E5%A2%83%E4%B8%8B%EF%BC%8Cjava%E8%B0%83%E7%94%A8Https%E6%8E%A5%E5%8F%A3%E6%8A%A5%E9%94%99&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~sobaiduweb~default-0-111322106.nonecase&spm=1018.2226.3001.4450

本地测试是否正常

http客户端发起ssl请求时,tls版本设置为1.2,SSLContext.getInstance("TLSv1.2") 确保你的ssl
版本是正确的

调用企业付款接口提示不支持的证书协议,是什么原因? | 微信开放社区 java.net.UnknownServiceException: Unable to find acceptable protocols. isFallback=false, modes=[ConnectionSpec(cipherSuites=[TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256, TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256, TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA, TLS_RSA_WITH_AES_128_GCM_SHA256, TLS_RSA_WITH_AES_256_GCM_SHA384, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA], tlsVersions=[TLS_1_3, TLS_1_2], supportsTlsExtensions=true), ConnectionSpec()], supported protocols=[TLSv1] https://developers.weixin.qq.com/community/pay/doc/000a8c7d4607f05e416db7c6c56000

img

https属于安全网络请求,需要有ssl认证,而http不需要该认证,你可以考虑修改为http的请求,也可以考虑吧对应的证书给加上,openssl工具生成证书。 具体的百度有很多,我就不一一列举了