title: x509 certificate subject DN
body: <p>I need to create a self signed certificate with my own the Subject DN. Example: I want to set username in Subject DN. I will retrieve this information using </p>
  
  <pre><code>X509Certificate.getSubjectDN().getName().
  </code></pre>
  
  <p>I was able to set the IssuserDN using -dname option of the keytool.</p>
  
  <pre><code>keytool -genkey -keyalg RSA -dname "CN=MyApp ACES CA 2, OU=MyApp Public Sector, O=MyApp, C=US"  -alias selfsigned -keystore keystore.jks -storepass password -validity 360 -keysize 2048 
  
  getIssuerDN().getName()
  getSubjectDN().getName()
  </code></pre>
  
  <p>prints following:</p>
  
  <pre><code>CN=MyApp ACES CA 2, OU=MyApp Public Sector, O=MyApp, C=US
  CN=MyApp ACES CA 2, OU=MyApp Public Sector, O=MyApp, C=US
  </code></pre>
  
  <p>Not sure how to set the Subject DN using java keytool or openssl.  </p>
  
  <p>Thanks</p>