Search code examples
opensslcertificatekeytoolcertificate-authority

Generate CSR with 2 OU Names


I have to create an application which generates a CSR. While generating a CSR we are required to fill in several details like CN, OU, etc. The problem is that the Certifying Authority to which I have to send my CSR wants 2 OU(Organizational Unit) Names. I googled a lot but couldn't find anything using either openssl or java keytool by which I can specify 2 OU Names.

Can someone please tell me how I can specify 2 OU Names while generating the CSR?


Solution

  • If you want to do it via CLI you can use either a conf file or pass the -subj argument. Here's an example with -subj

    openssl req -new -newkey rsa:2048 -nodes -subj "/CN=somedomain.com/O=My Corporation/OU=Org Unit 1/OU=Org Unit 2"
    

    You can add in ST, L, C, and any other shortName OpenSSL recognizes (along with raw OIDs).