简体   繁体   English

如何在OCSP请求中使用代理

[英]how to use proxy in OCSP request

I need to validate X509 Certificate using OCSP using http proxy. 我需要使用HTTP代理使用OCSP验证X509证书。 Here is my code: 这是我的代码:

                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);

I know, that I can set proxy using System.setProperty("http.proxy", "...") but I need to set it only for my request, not for whole system. 我知道,我可以使用System.setProperty(“ http.proxy”,“ ...”)设置代理,但是我只需要为我的请求设置代理,而不是为整个系统设置代理。

我找到了基于一个Apache Open Source项目Apache Open Source项目编写自己的OCSP验证代码的最简单方法,并将其扩展为使用可配置的HTTP代理进行请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM