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

Update JSSTrustManager to support trusted peers #1017

Merged
merged 1 commit into from
Aug 7, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,36 @@ public void checkCertChain(X509Certificate[] certChain, String keyUsage) throws
logger.debug("JSSTrustManager: - " + cert.getSubjectX500Principal());
}

checkIssuerTrusted(certChain);
if (!isTrustedPeer(certChain)) {
checkIssuerTrusted(certChain);
}

checkValidityDates(certChain);

checkKeyUsage(certChain, keyUsage);
}

public boolean isTrustedPeer(X509Certificate[] certChain) throws Exception {

// checking trust flags on leaf cert only
X509Certificate leafCert = certChain[certChain.length - 1];
logger.debug("JSSTrustManager: Checking trust flags of cert 0x" + leafCert.getSerialNumber().toString(16));

if (! (leafCert instanceof org.mozilla.jss.crypto.X509Certificate)) {
return false;
}

org.mozilla.jss.crypto.X509Certificate jssCert = (org.mozilla.jss.crypto.X509Certificate) leafCert;

String trustFlags = jssCert.getTrustFlags();
logger.debug("JSSTrustManager: - trust flags: " + trustFlags);

int sslTrust = jssCert.getSSLTrust();
return org.mozilla.jss.crypto.X509Certificate.isTrustFlagEnabled(
org.mozilla.jss.crypto.X509Certificate.TRUSTED_PEER,
sslTrust);
}

public void checkIssuerTrusted(X509Certificate[] certChain) throws Exception {

// get CA certs
Expand Down
Loading