public static CertificateXO asCertificateXO(final Certificate certificate, final boolean inNexusSSLTrustStore)
throws Exception
{
final String fingerprint = calculateFingerprint(certificate);
final CertificateXO certificateXO = new CertificateXO()
.withId(fingerprint)
.withPem(CertificateUtil.serializeCertificateInPEM(certificate))
.withFingerprint(fingerprint);
if (certificate instanceof X509Certificate) {
final X509Certificate x509Certificate = (X509Certificate) certificate;
final Map<String, String> subjectRdns = getSubjectRdns(certificate);
final Map<String, String> issuerRdns = getIssuerRdns(certificate);
certificateXO
.withSerialNumber(x509Certificate.getSerialNumber().toString())
.withSubjectCommonName(subjectRdns.get("CN"))
.withSubjectOrganization(subjectRdns.get("O"))
.withSubjectOrganizationalUnit(subjectRdns.get("OU"))
.withIssuerCommonName(issuerRdns.get("CN"))