在 https demo的基础上新增代码
System.setProperty("https.proxyHost", "127.0.0.1");
System.setProperty("https.proxyPort", "8888");
检验服务器端证书相关的代码
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
try {
pkixTrustManager.checkServerTrusted(chain, authType);
} catch (CertificateException e) {
e.printStackTrace();
}
}
chain[0]的信息如下
[[
[
Version: V3
Subject: CN=192.168.1.100, O=DO_NOT_TRUST, OU=Created by http://www.fiddler2.com
Signature Algorithm: SHA256withRSA, OID = 1.2.840.113549.1.1.11
Key: Sun RSA public key, 2048 bits
modulus: 24947351780810750149457192342624891094010340826566576952405861651562219499162480072742194129566797520741499176032489646316170314955835686646980297758424985554421943435601176370704615459227197142976029945830796314782808168867122283837438799297051330390738395916999777595862184321998752239481037639477824388751868106166359017794514693196099598252592968561371591176844590654131704730811194193636860112321674716596633253287199014920205230667327198840802362660975939107706467998611424982214405584353521096452464329878819175737107584601577502327373070485795864908400431388188336555021702892277221877718950834967106784349929
public exponent: 65537
Validity: [From: Sat Jan 02 03:08:02 C