Stop log warning about unique identifier when it shouldn't be loged
@@ -85,21 +85,28 @@ public class CertificateModel {
this.notAfter = certificate.getNotAfter().toString();
this.publicKey = certificate.getPublicKey().toString();
this.publicKeyAlgorithm = certificate.getPublicKey().getAlgorithm().toString();
+ // rfc5280 in section 4.1.2.8. Unique Identifiers
+ // "CAs conforming to this profile MUST NOT generate certificates with unique identifiers."
+ // "These fields MUST NOT appear if the version is 1."
+ if (version != 1 && ((certificate.getKeyUsage() != null && certificate.getKeyUsage()[5] == false)
+ || certificate.getBasicConstraints() == -1)) {
try {
this.issuerUniqueID = certificate.getIssuerUniqueID().toString();
} catch (NullPointerException e) {
- Log.warning("Certificate doesn't have issuerUniqueID ", e);
+ Log.warning("Certificate doesn't have issuerUniqueID: " + issuer, e);
}
try {
this.subjectUniqueID = certificate.getIssuerUniqueID().toString();
} catch (NullPointerException e) {
- Log.warning("Certificate doesn't have subjectUniqueID ", e);
+ Log.warning("Certificate doesn't have subjectUniqueID: " + subject, e);
+ }
}
try {
this.subjectCommonName = extractCommonName(subject);
} catch (InvalidNameException e) {
Log.warning("Couldn't extract subject Common Name (CN)", e);
}
+
try {
this.issuerCommonName = extractCommonName(issuer);
} catch (InvalidNameException e) {
