java验证ssl证书的有效性 需要预置CA中心的根证书(多个),然后验证这些CA中心发的证书。根证书都是公开的,可以从CA中心的网站下载 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://blog.sina.com.cn/s/blog_51a7b40e010100kn.html别人的代码你搜索“ java 证书链” 如果我想在发url链接的时候来验证证书的合法性呢?也就是浏览器端验证我该如何做?我该如何修改下面的代码?SSLContextBuilder builder = new SSLContextBuilder(); builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); //这里自签名信任了。 SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); CloseableHttpClient client = HttpClients.custom().setSSLSocketFactory(sslsf).build();HttpPost httpPost = new HttpPost(url); CloseableHttpResponse httpResp = client.execute(httpPost); try { code = httpResp.getStatusLine().getStatusCode(); HttpEntity entity = httpResp.getEntity(); if (entity != null) { resp = EntityUtils.toString(entity); } } finally { httpResp.close(); client.close(); }如果我想在上面的代码验证证书改如何做? 关于付款的流程问题 Mysql 数据表中存在脏数据,用JAVA怎么处理? 写一个类倒叙输出“hello,world” 求bbs源代码 求救关于java swing的问题,为什么事件触发会不按套路出牌 XBeanNamespaceHandler webservice问题 getClass().getResourceAsStream 问题 我想用jsp显示数据表表头的值?可是显示出来是乱码! 请教高手jbuilder支持工作流技术吗?如xlang ,wsfl ,bpws等。 Glassfish4.1怎么启用SSI 求助,流媒体播放卡。这个一定要真的勇士来解决。
SSLContextBuilder builder = new SSLContextBuilder();
builder.loadTrustMaterial(null, new TrustSelfSignedStrategy()); //这里自签名信任了。
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(builder.build(), SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
CloseableHttpClient client = HttpClients.custom().setSSLSocketFactory(sslsf).build();
HttpPost httpPost = new HttpPost(url);
CloseableHttpResponse httpResp = client.execute(httpPost);
try {
code = httpResp.getStatusLine().getStatusCode();
HttpEntity entity = httpResp.getEntity();
if (entity != null) {
resp = EntityUtils.toString(entity);
}
} finally {
httpResp.close();
client.close();
}
如果我想在上面的代码验证证书改如何做?