title: How to extract CN from X509Certificate in Java?
body: <p>I am using a <code>SslServerSocket</code> and client certificates and want to extract the CN from the SubjectDN from the client's <code>X509Certificate</code>.</p>
  
  <p>At the moment I call <code>cert.getSubjectX500Principal().getName()</code> but this of course gives me the total formatted DN of the client. For some reason I am just interested in the <code>CN=theclient</code> part of the DN. Is there a way to extract this part of the DN without parsing the String myself?</p>