2017-04-25 21 views
1

我需要使用http代理验证使用OCSP的X509证书。这里是我的代码:如何在OCSP请求中使用代理

   List<X509Certificate> certificates = Collections.singletonList(certificate); 
      CertPath cp = factory.generateCertPath(certificates); 
      Set<TrustAnchor> trust = new HashSet<>(); 
      trust.add(new TrustAnchor(issuerCertificate, null)); 
      PKIXParameters params = new PKIXParameters(trust); 
      params.setRevocationEnabled(true); 
      CertPathValidator cpv = 
        CertPathValidator.getInstance(CertPathValidator.getDefaultType()); 

      PKIXCertPathValidatorResult validationResult = 
        (PKIXCertPathValidatorResult) cpv.validate(cp, params); 

我知道,我可以设置使用 System.setProperty代理(“http.proxy”,“...”),但我需要设置只对我的要求,不整个系统。

回答

0

我发现写一个基于Apache开源的一个自己的OCSP验证码,最简单的方法项目Apache Open Source projects 并延长其使用可配置的HTTP代理的请求