将CSR专有名称字段作为参数传递给OpenSSL

Dus*_*rea 21 openssl csr

如何在不需要用户输入的情况下生成CSR,例如从应用程序中生成CSR?

Dus*_*rea 40

通过"-subj"参数传递主题:

openssl req -new -key <private key file> -out <CSR output file> -subj "/C=<Country Name>/ST=<State>/L=<Locality Name>/O=<Organization Name>/CN=<Common Name>"
Run Code Online (Sandbox Code Playgroud)

请注意,如果要让OpenSSL为您构建主题字符串,可以像往常一样创建CSR,然后执行命令对其进行自签名.完美格式化的主题行将在顶部回显("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
...
Run Code Online (Sandbox Code Playgroud)