如何在IBMJava1.6中启用TLS1.2?
我需要在IBMJava1.6[SR16FP60]中启用TLS1.2连接。我试图通过以下方式建立联系:如何在IBMJava1.6中启用TLS1.2?,java,websphere,tls1.2,sslhandshakeexception,Java,Websphere,Tls1.2,Sslhandshakeexception,我需要在IBMJava1.6[SR16FP60]中启用TLS1.2连接。我试图通过以下方式建立联系: public static void TLS() throws NoSuchAlgorithmException, KeyManagementException, IOException{ System.setProperty("https.protocols", "TLSv1.2"); URL url = new URL("https://jsonplaceholder.typi
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());}
}
publicstaticvoidtls()抛出nosuchagorithmexception、KeyManagementException、IOException{
System.setProperty(“https.protocols”、“TLSv1.2”);
URL=新URL(“https://jsonplaceholder.typicode.com/posts");
字符串XML=“”
sslcontextssl=SSLContext.getInstance(“TLSv1.2”);
//init(null,null,null);
init(null,null,null);
SSLContext.setDefault(ssl);
HttpsURLConnection连接=(HttpsURLConnection)url.openConnection();
setsslssocketfactory(ssl.getSocketFactory());
connection.setRequestMethod(“POST”);
setRequestProperty(“内容类型”、“应用程序/xml”);
connection.setDoOutput(真);
OutputStream os=connection.getOutputStream();
write(XML.getBytes());
os.flush();
os.close();
System.out.println(“>>>连接证书”+Connection.getServerCertificates());
System.out.println(“>>>Connection”+Connection.getContent());
int responseCode=connection.getResponseCode();
System.out.println(“后响应代码:+responseCode”);
System.out.println(“POST响应消息:+connection.getResponseMessage());
如果(responseCode==HttpsURLConnection.HTTP_OK){//success
BufferedReader in=新的BufferedReader(新的InputStreamReader(
getInputStream());
字符串输入线;
StringBuffer响应=新的StringBuffer();
而((inputLine=in.readLine())!=null){
追加(inputLine);
}in.close();
System.out.println(response.toString());}
}
在建立连接时,它抛出了一个错误
收到致命警报:握手失败
请告知我们如何解决此问题。我猜您正在使用WebSphere 6?您必须升级到7.0.0.23、8.0.0.3或8.5
请参见我想您正在使用WebSphere 6?您必须升级到7.0.0.23、8.0.0.3或8.5
请参见谢谢@nic。我正在使用WebSphere7.0和Java1.6[SR16FP60]。我认为IBM java 1.6中的TLS 1.2支持请建议Thank@nic。我正在使用WebSphere7.0和Java1.6[SR16FP60]。我认为IBM java 1.6中的TLS 1.2支持请告知