我想对ssl上下文使用TLS/TLSv1.2:
SSLContext context = SSLContext.getInstance("TLSv1.2");
context.init(new KeyManager[] { km }, new TrustManager[] { new MyTrustStore(keyStore) }, new SecureRandom());
System.out.println("PROTOCOL: "+SSLContext.getDefault().getSupportedSSLParameters().getProtocols()[0]);
我们正在使用自定义的信任库和密钥管理器,在这里忽略它,但我们确实需要它们。
现在,它每次都会打印"SSLv2Hello“。
我都试过了
SSLContext context = SSLContext.getInstance("TLSv1.2");
和
SSLContext context = SSLContext.getInstance("TLS");
两个都不管用。
作为参考,此程序在JDK 1.8.0_171上运行。
谢谢你的帮助
发布于 2020-04-14 18:03:28
您可以尝试自定义方式。下面是一个kotlin示例
val sslContext = SSLContexts.custom().setProtocol("TLSv1.2").build()
参考:How to fix 'SSLHandshakeException: Received fatal alert: decode_error'?
https://stackoverflow.com/questions/61214106
复制