/** * Gets the common name attribute (CN) of the certificate subject distinguished name. * * @param cert Certificate to examine. * * @return Subject CN or null if no CN attribute is defined in the subject DN. * * @throws EncodingException on cert field extraction. */ public static String subjectCN(final X509Certificate cert) throws EncodingException { return new NameReader(cert).readSubject().getValue(StandardAttributeType.CommonName); }