如何在OCSP请求中使用代理
问题描述:
我需要使用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”,“...”),但我需要设置只对我的要求,不整个系统。