javax.net.ssl.SSLHandshakeException: Server chose TLSv1, but that protocol version is not enabled or not supported by the client.
報錯顯示:服務器端採用TLSv1 版本協議 (前身是ssl),可是客戶端不支持或者未開啓該版本java
我本地是開發,使用okhttp去訪問的該https網站,這證實是該端協議不支持服務器
server:查看 本地開發端 server 支持與開啓tls 信息socket
public static void main(String[] args) throws Exception { SSLContext context = SSLContext.getInstance("TLS"); context.init(null, null, null); SSLSocketFactory factory = (SSLSocketFactory) context.getSocketFactory(); SSLSocket socket = (SSLSocket) factory.createSocket(); String[] protocols = socket.getSupportedProtocols(); System.out.println("Supported Protocols: " + protocols.length); for (int i = 0; i < protocols.length; i++) { System.out.println(" " + protocols[i]); } protocols = socket.getEnabledProtocols(); System.out.println("Enabled Protocols: " + protocols.length); for (int i = 0; i < protocols.length; i++) { System.out.println(" " + protocols[i]); } }
結果:網站
Supported Protocols: 5 SSLv2Hello SSLv3 TLSv1 TLSv1.1 TLSv1.2 Enabled Protocols: 3 TLSv1 TLSv1.1 TLSv1.2