服务器端和客户端均停用sslv3协议,客户端请求的协议的SSLv3未启用或不支持(IBM JDK 6.0SR10)...

的异常时,客户端和服务器的SSL协议设置不匹配发生。

以下客户端的示例代码可与服务器侧配置支承TLSv1.2工作协议:

String response = "";

URL url = new URL("https://localhost:9043/myservlet);

final SSLContext ctx = SSLContext.getInstance("TLSv1.2");

ctx.init(null, null, null);

// final String protoccol = ctx.getProtocol();

HttpsURLConnection.setDefaultSSLSocketFactory(ctx.getSocketFactory());

final HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();

conn.setReadTimeout(15000);

conn.setConnectTimeout(15000);

conn.setRequestMethod("POST");

conn.setDoInput(true);

conn.setDoOutput(true);

final OutputStream os = conn.getOutputStream();

final BufferedWriter writer =

new BufferedWriter(new OutputStreamWriter(os, "UTF-8"));

writer.write(......);

writer.flush();

writer.close();

os.close();

final int responseCode = conn.getResponseCode();

if (responseCode == HttpsURLConnection.HTTP_OK) {

String line;

final BufferedReader br =

new BufferedReader(new InputStreamReader(conn.getInputStream()));

while ((line = br.readLine()) != null) {

response += line;

}

}

System.out.println("response: " + response);