如何在 IBM java 1.6 中启用 TLS 1.2?
Posted
技术标签:
【中文标题】如何在 IBM java 1.6 中启用 TLS 1.2?【英文标题】:How to Enable a TLS 1.2 in IBM java 1.6? 【发布时间】:2019-03-18 22:12:16 【问题描述】:我需要在 IBM Java 1.6[SR16 FP60] 中启用 TLS 1.2 连接。我尝试通过
建立连接 public static void TLS() throws NoSuchAlgorithmException, KeyManagementException, IOException
System.setProperty("https.protocols", "TLSv1.2");
URL url = new URL("https://jsonplaceholder.typicode.com/posts");
String XML = "<Test></test>"
SSLContext ssl = SSLContext.getInstance("TLSv1.2");
// ctx.init(null, null, null);
ssl.init(null, null, null);
SSLContext.setDefault(ssl);
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
connection.setSSLSocketFactory(ssl.getSocketFactory());
connection.setRequestMethod("POST");
connection.setRequestProperty("Content-Type", "application/xml");
connection.setDoOutput(true);
OutputStream os = connection.getOutputStream();
os.write(XML.getBytes());
os.flush();
os.close();
System.out.println(">>>Connection certificate"+connection.getServerCertificates());
System.out.println(">>>Connection"+connection.getContent());
int responseCode = connection.getResponseCode();
System.out.println("POST Response Code : " + responseCode);
System.out.println("POST Response Message : " + connection.getResponseMessage());
if (responseCode == HttpsURLConnection.HTTP_OK) //success
BufferedReader in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in .readLine()) != null)
response.append(inputLine);
in .close();
System.out.println(response.toString());
在建立连接时抛出错误
收到致命警报:handshake_failure
请告知我们解决此问题的方法。
【问题讨论】:
【参考方案1】:我猜你正在使用 WebSphere 6?您必须升级到 7.0.0.23、8.0.0.3 或 8.5。
见https://developer.ibm.com/answers/questions/206952/how-do-i-configure-websphere-application-server-ss.html
【讨论】:
谢谢@nic。我正在使用 websphere 7.0 和 Java Java 1.6[SR16 FP60]。我认为 IBM java 1.6 支持 TLS 1.2 ***.com/questions/33364100/… 请指教 developer.ibm.com/answers/questions/351300/…以上是关于如何在 IBM java 1.6 中启用 TLS 1.2?的主要内容,如果未能解决你的问题,请参考以下文章
在 IBM J9 下从 Java 1.5 升级到 1.6 时 JNI 的链接问题