0

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

X509Certificate.getSubjectDN().getName().

I was able to set the IssuserDN using -dname option of the keytool.

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()

prints following:

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

Not sure how to set the Subject DN using java keytool or openssl.

Thanks

Raj
  • 359
  • 1
  • 3
  • 12
  • Please show your code, and point out where you are encountering the problem. Be sure to provide the exact error message at the point of failure. – jww Apr 26 '17 at 15:33
  • Updated the description – Raj Apr 26 '17 at 16:00
  • In a self-signed certificate subject and issuer DN are always the same. – Omikron Apr 26 '17 at 18:32
  • Thanks @Omikron. I thought there is a way to set Subject different than issuer in the self signed certificate. – Raj Apr 26 '17 at 18:35

0 Answers0