Passing CSR distinguished-name fields as parameters to OpenSSL

后端 未结 1 1041
孤街浪徒
孤街浪徒 2021-02-04 00:06

How can you generate a CSR without requiring user input, such as to generate CSRs from within an application?

1条回答
  •  无人共我
    2021-02-04 00:51

    Pass the subject via the "-subj" argument:

    openssl req -new -key  -out  -subj "/C=/ST=/L=/O=/CN="
    

    Note that if you want to have OpenSSL build the subject string for you, you can create the CSR as you normally would, and then execute the command to self-sign it. A perfectly formatted subject line will be echoed-out at the top ("subject="):

    openssl x509 -req -days 365 -in server.csr -signkey server.pem
    
    Loading 'screen' into random state - done
    Signature ok
    subject=/C=US/ST=Florida/L=Miami/O=Test Group/CN=testgroup.server5
    Getting Private key
    ...
    

    0 讨论(0)
提交回复
热议问题