java 主動信任證書

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);
相關文章
相關標籤/搜索