I want to retrieve a string from the certificate subject field but only its CN value.
to get the whole string I use:
Enumeration enumeration = ks.aliases();
while (enumeration.hasMoreElements()) {
String aliass = (String) enumeration.nextElement();
X509Certificate cer = (X509Certificate) ks.getCertificate(aliass);
String s = cer.getSubjectDN().getName().;
System.out.println(s);
}
output is: CN=something, OU=something, DC=something, DC=something, DC=someting
as stated I want to retrieve only the CN string. is there a short way about it or I should play with substring methods to get the field, also that would not be my preferred way because some certs.getName() are starting with their email address.