我在代码中禁用证书时遇到问题。在代码中:
ember-cli
然后抛出异常:
ember-cli
但如果我在跑步者中加入intellij:
System.setProperty("jsse.enableSNIExtension", "false");
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy());
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
builder.build());
CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(
sslsf).build();
HttpGet httpGet = new HttpGet("https://interkar.pl/bok/");
CloseableHttpResponse response = httpclient.execute(httpGet);
try {
System.out.println(response.getStatusLine());
HttpEntity entity = response.getEntity();
EntityUtils.consume(entity);
}
finally {
response.close();
}
然后我得到预期的结果,但如何在代码中解决?
我使用java 8和HttpClient是:
javax.net.ssl.SSLProtocolException: handshake alert: unrecognized_name