2

I need to validate X509 Certificate using OCSP using http proxy. 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.

Loginus
  • 151
  • 8
  • 1
    Just to prevent mistakes: the java property for configuring the proxy is *not* `http.proxy`. It is `http.proxyHost` and `http.proxyPort`, see https://stackoverflow.com/a/120802/4864870. – Josef Reichardt Mar 21 '19 at 12:59

1 Answers1

0

I found the easiest way to write own OCSP verification code based on one of Apache Open Source projects Apache Open Source projects and extend it to use configurable HTTP proxy for request

Loginus
  • 151
  • 8