java 主动信任证书

java 主动信任证书

SSLContext sslcontext = SSLContexts.custom().loadKeyMaterial(keyStore, mid.toCharArray()).loadTrustMaterial(keyStore, new TrustStrategy() {
    // 信任所有
    public boolean isTrusted(java.security.cert.X509Certificate[] chain, String authType) {
        return true;
    }
}).build();

SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslcontext, new String[] { "TLSv1" },
            null, SSLConnectionSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);

 

上一篇:AndroidKeyStore getEntry在某些点后一直失败


下一篇:小白科普之JavaScript的DOM模型