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」,「...」),但我需要設置只對我的要求,不整個系統。