title: Retrieving subject/CN field from a certificate?
body: <p>I want to retrieve a string from the certificate subject field but only its CN value.</p>
  
  <p>to get the whole string I use:</p>
  
  <pre><code>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);
  }
  </code></pre>
  
  <p>output is: CN=something, OU=something, DC=something, DC=something, DC=someting</p>
  
  <p>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.</p>