javax.net.ssl.SSLHandshakeException: Server chose TLSv1, but that protocol version is not enabled or not supported by the client.
報錯顯示:服務器端采用TLSv1 版本協議 (前身是ssl),但是客戶端不支持或者未開啟該版本
我本地是開發,使用okhttp去訪問的該https網站,這證明是該端協議不支持
server:查看 本地開發端 server 支持與開啟tls 信息
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