完整的代理访问测试程序如下
static class MyX509TrustManager implements X509TrustManager {
/*
* The default X509TrustManager returned by IbmX509. We'll delegate decisions to it, and fall back to the logic in this class if the default X509TrustManager doesn't trust it.
*/
private X509TrustManager pkixTrustManager;
public MyX509TrustManager() throws Exception {
// create a "default" JSSE X509TrustManager.
// KeyStore用于存放证书,创建对象时 指定交换数字证书的加密标准
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
// 加载证书库keystore文件
keyStore.load(new FileInputStream("C:/Users/coffee/Desktop/coffee-100.keystore"), "coffee".toCharArray());
// keyStore.load(new FileInputStream("F:/Java/jdk1.7.0_79/jre/lib/security/Fiddler.Keystore"), "changeit".toCharArray());
// TrustManager决定是否信任对方的证书
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFact