CertUtil { public static String getCommonName(X509Certificate cert) { try { return getValueByObjectIdentifier(cert, BCStyle.CN).replaceAll("\\\\", ""); } catch (CertificateEncodingException e) { LOGGER.error("Error extracting common name from certificate", e); return null; } }  static String getCountryCode(X509Certificate cert); static String getCommonName(X509Certificate cert); static String encodeCertificateToBase64(X509Certificate certificate);  }
@Test public void validCommonNameFromCertificate() throws CertificateException { Assert.assertEquals("VOLL,ANDRES,39004170346", CertUtil.getCommonName(getCertificate())); }