0

I'm creating a certificate using this command:

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -config localhost.conf

with this config:

[req]
default_bits       = 2048
default_keyfile    = localhost.key
distinguished_name = req_distinguished_name
req_extensions     = req_ext
x509_extensions    = v3_ca

[req_distinguished_name] commonName = Common Name (e.g. server FQDN or YOUR name) commonName_default = localhost commonName_max = 64

[req_ext] subjectAltName = @alt_names

[v3_ca] subjectAltName = @alt_names basicConstraints = critical, CA:false keyUsage = keyCertSign, cRLSign, digitalSignature,keyEncipherment

[alt_names] DNS.1 = localhost

But the command asks for a Common name and password, How can I send them as the parameter to openssl. I tried other solutions but none of them worked.

saeed
  • 161

1 Answers1

0

You can use -subj on the command line to pass the certificate's Subject.

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout localhost.key -out localhost.crt -config localhost.conf -subj "/O=My Org/OU=My Dept/CN=My Service"
garethTheRed
  • 4,404