Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OCSP verification of requests hashes #4537

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions base/ocsp/src/main/java/com/netscape/cms/ocsp/LDAPStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ public SingleResponse processRequest(Request req) throws Exception {

Enumeration<X509CertImpl> caCerts = mCRLs.keys();

MessageDigest md = MessageDigest.getInstance(cid.getDigestName());
while (caCerts.hasMoreElements()) {
X509CertImpl caCert = caCerts.nextElement();
MessageDigest md = MessageDigest.getInstance(cid.getDigestName());
logger.debug("LDAPStore: processRequest: cert digest name=" +
cid.getDigestName());
X509Key key = (X509Key) caCert.getPublicKey();
Expand All @@ -400,18 +400,20 @@ public SingleResponse processRequest(Request req) throws Exception {
throw new Exception("Missing issuer key");
}

byte digest[] = md.digest(key.getKey());
byte keyhsh[] = cid.getIssuerKeyHash().toByteArray();
byte[] digest = md.digest(key.getKey());
byte[] keyhsh = cid.getIssuerKeyHash().toByteArray();

if (!Arrays.equals(digest, keyhsh)) {
logger.debug("LDAPStore: processRequest: CA key digest and cert issuer key hash do not match; continue to look at next CA in mCRLs...");
continue;
}

theCert = caCert;
incReqCount(caCert.getSubjectDN().toString());
theCRL = mCRLs.get(caCert);
break;
byte[] name = md.digest(caCert.getSubjectObj().getX500Name().getEncoded());
byte[] namehash = cid.getIssuerNameHash().toByteArray();

if (Arrays.equals(digest, keyhsh) && Arrays.equals(name, namehash)) {
theCert = caCert;
incReqCount(caCert.getSubjectX500Principal().getName());
theCRL = mCRLs.get(caCert);
break;
}
logger.debug("LDAPStore: processRequest: CA key digest and cert issuer key hash do not match; continue to look at next CA in mCRLs...");
}

if (theCert == null) {
Expand Down