Skip to content

Commit

Permalink
Add support for certificates without cn
Browse files Browse the repository at this point in the history
  • Loading branch information
JBWatenbergScality committed Oct 2, 2024
1 parent 398797f commit b739688
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,13 @@ private CertificateRepresentation toCertificateRepresentation(TruststoreEntity e
X509Certificate x509Certificate = toX509Certificate(entity.getCertificate());
try {
X500Name x500name = new JcaX509CertificateHolder(x509Certificate).getSubject();
RDN cn = x500name.getRDNs(BCStyle.CN)[0];
RDN[] rdns = x500name.getRDNs(BCStyle.CN);
RDN cn = rdns.length > 0 ? rdns[0] : null;

CertificateRepresentation certificate = new CertificateRepresentation(
entity.getAlias(),
entity.getCertificate(),
IETFUtils.valueToString(cn.getFirst().getValue()));
cn != null ? IETFUtils.valueToString(cn.getFirst().getValue()) : "-");

return certificate;

Expand Down

0 comments on commit b739688

Please sign in to comment.