CertUtil { public static String getCountryCode(X509Certificate cert) { try { return getValueByObjectIdentifier(cert, BCStyle.C); } catch (CertificateEncodingException e) { LOGGER.error("Error extracting country from certificate", e); return null; } }  static String getCountryCode(X509Certificate cert); static String getCommonName(X509Certificate cert); static String encodeCertificateToBase64(X509Certificate certificate);  }
@Test public void validCountryFromCertificate() throws CertificateException { Assert.assertEquals("EE", CertUtil.getCountryCode(getCertificate())); }