Our use-case requires validating certificate revocation via OCSP on a PKIX set-up. My starting point was the code at this related question: OCSP Revocation on client certificate
I'm doing it manually at the application level since tomcat doesn't support it. However, I'm having some trouble building the certPath and I think I'm missing some fundamental understanding.
First I try to create the certPath for the incoming client x509Certificate.
KeyStore store is initialized correctly and contains only the root certificates that match the client x509Certificate.
EDIT: I got the same result after adding the intermediate certificates as well.
X509CertSelector certSelector = new X509CertSelector();
certSelector.setSubject(x509certificate.getSubjectX500Principal());
PKIXParameters params = new PKIXBuilderParameters(store,certSelector);
CertPathBuilder cpb = CertPathBuilder.getInstance(CertPathBuilder.getDefaultType());
CertPath certPath = cpb.build(params).getCertPath();
However, I get an error at run-time:
sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
What could be missing?