mirror of
https://github.com/nsacyber/HIRS.git
synced 2025-02-20 17:52:47 +00:00
Updated the CA certificate to truncate the prefix of the subject key identifier
This commit is contained in:
parent
2263a3567f
commit
00d8dfb3b5
@ -25,6 +25,8 @@ public class CertificateAuthorityCredential extends Certificate {
|
||||
*/
|
||||
public static final String SUBJECT_KEY_IDENTIFIER_FIELD = "subjectKeyIdentifier";
|
||||
|
||||
private static final int CA_BYTE_SIZE = 20;
|
||||
|
||||
@Column
|
||||
private final byte[] subjectKeyIdentifier;
|
||||
|
||||
@ -85,8 +87,16 @@ public class CertificateAuthorityCredential extends Certificate {
|
||||
public CertificateAuthorityCredential(final byte[] certificateBytes)
|
||||
throws IOException {
|
||||
super(certificateBytes);
|
||||
this.subjectKeyIdentifier =
|
||||
getX509Certificate().getExtensionValue(SUBJECT_KEY_IDENTIFIER_EXTENSION);
|
||||
byte[] tempBytes = getX509Certificate()
|
||||
.getExtensionValue(SUBJECT_KEY_IDENTIFIER_EXTENSION);
|
||||
|
||||
if (tempBytes.length > CA_BYTE_SIZE) {
|
||||
this.subjectKeyIdentifier = truncatePrefixBytes(tempBytes);
|
||||
} else {
|
||||
this.subjectKeyIdentifier =
|
||||
getX509Certificate().getExtensionValue(SUBJECT_KEY_IDENTIFIER_EXTENSION);
|
||||
}
|
||||
|
||||
if (this.subjectKeyIdentifier != null) {
|
||||
this.subjectKeyIdString = Hex.encodeHexString(this.subjectKeyIdentifier);
|
||||
}
|
||||
@ -103,8 +113,18 @@ public class CertificateAuthorityCredential extends Certificate {
|
||||
public CertificateAuthorityCredential(final Path certificatePath)
|
||||
throws IOException {
|
||||
super(certificatePath);
|
||||
this.subjectKeyIdentifier =
|
||||
getX509Certificate().getExtensionValue(SUBJECT_KEY_IDENTIFIER_EXTENSION);
|
||||
byte[] tempBytes = getX509Certificate()
|
||||
.getExtensionValue(SUBJECT_KEY_IDENTIFIER_EXTENSION);
|
||||
|
||||
if (tempBytes.length > CA_BYTE_SIZE) {
|
||||
this.subjectKeyIdentifier = truncatePrefixBytes(tempBytes);
|
||||
} else {
|
||||
this.subjectKeyIdentifier =
|
||||
getX509Certificate().getExtensionValue(SUBJECT_KEY_IDENTIFIER_EXTENSION);
|
||||
}
|
||||
if (this.subjectKeyIdentifier != null) {
|
||||
this.subjectKeyIdString = Hex.encodeHexString(this.subjectKeyIdentifier);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,6 +161,13 @@ public class CertificateAuthorityCredential extends Certificate {
|
||||
return this.subjectKeyIdString;
|
||||
}
|
||||
|
||||
private byte[] truncatePrefixBytes(final byte[] certificateBytes) {
|
||||
byte[] temp = new byte[CA_BYTE_SIZE];
|
||||
System.arraycopy(certificateBytes, 4, temp, 0, CA_BYTE_SIZE);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("checkstyle:avoidinlineconditionals")
|
||||
public boolean equals(final Object o) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user