gpt4 book ai didi

java - 如何在 IBM java 1.6 中启用 TLS 1.2?

转载 作者:行者123 更新时间:2023-12-02 01:52:27 26 4
gpt4 key购买 nike

我需要在 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());}

}

建立连接时抛出错误

Received Fatal alert : handshake_failure

请告知我们如何解决此问题。

最佳答案

我猜您正在使用 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

关于java - 如何在 IBM java 1.6 中启用 TLS 1.2?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52800535/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com