Search code examples
javakeystoreca

How to generate keystore only with C/O/OU/CN by JAVA keytool


I'm using java keytool to generate keystore for server.

It contains

1.CN 
2.OU
3.O
4.L 
5.ST
6.C

But customize CA only has

1.CN
2.OU
3.O
4.C

How to generate keystore only with C/O/OU/CN by JAVA keytool?


Solution

  • It's not clear to me what you mean by 'customize CA'.

    If you are talking about the selfsigned cert created automatically by -genkeypair, which doesn't actually involve any CA although it does have a name in Subject and Issuer, the latter of which would normally be a CA name:

    • if using prompting answer the applicable questions and enter nothing (just CR) for the others

    • if using -dname specify the desired attributes and don't specify the others

    If you mean requesting a cert from a CA, you can control what goes in the request (CSR) with -dname, but the CA can ignore that; only the CA controls what goes in the cert, and since you haven't said anything about who the CA is, it's impossible to even attempt to answer.