While ssl handshake, I get the following error:
Certificate contains unsupported critical extensions.
This exception is thrown by sun.security.validator.EndEntityChecker class
private void checkRemainingExtensions(Set<String> exts)
throws CertificateException {
// basic constraints irrelevant in EE certs
exts.remove(SimpleValidator.OID_BASIC_CONSTRAINTS);
// If the subject field contains an empty sequence, the subjectAltName
// extension MUST be marked critical.
// We do not check the validity of the critical extension, just mark
// it recognizable here.
exts.remove(OID_SUBJECT_ALT_NAME);
if (!exts.isEmpty()) {
throw new CertificateException("Certificate contains unsupported "
+ "critical extensions: " + exts);
}
}
It turns out that extension, which causes the error is the only one not removed during the validation process. Removing this extension from CA is not an option. How can I whitelist this extension?
You can write a
PKIXCertPathCheckerthat processes and removes this extension, and then add that as a checker using thePKIXParameters.addCertPathCheckermethod, and then set those parameters using theTrustManagerFactory.initmethod.