1

Trying to get certificate v3, but getting v1. I'm using following commands:

openssl req -out server.csr -newkey rsa:2048 -nodes -keyout server.key -config san_server.cnf
openssl ca -config san_server.cnf -create_serial -batch -in server.csr -out server.crt

Configuration file san_server.cnf content:

[ca]
default_ca=CA_default

[CA_default]
dir=./ca
database=$dir/index.txt
new_certs_dir=$dir/newcerts
serial=$dir/serial
private_key=./ca.key
certificate=./ca.crt
default_days=3650
default_md=sha256
policy=policy_anything
copy_extensions=copyall

[policy_anything]
countryName=optional
stateOrProvinceName=optional
localityName=optional
organizationName=optional
organizationalUnitName=optional
commonName=optional
emailAddress=optional

[req]
prompt=no
distinguished_name=req_distinguished_name
req_extensions=v3_req
x509_extensions=v3_ca

[req_distinguished_name]
countryName=EN
stateOrProvinceName=Some-State
localityName=London
organizationName=Internet Widgits Pty Ltd
commonName=192.168.1.8

[v3_req]
subjectAltName=@alt_names

[v3_ca]
subjectAltName=@alt_names

[alt_names]
IP.1=127.0.0.1
IP.2=192.168.1.8
DNS.1=localhost

As a result I got v1 certificate. How to create v3 one?

1

If you are using OpenSSL below 1.0.2g 1.1.0m (both Nov. 2017) or 1.1.1 (Sep. 2018) there was a bug that did this -- see https://unix.stackexchange.com/questions/393601/local-ssl-certificates-in-chrome-ium-63/ -- and my workaround at https://unix.stackexchange.com/questions/371997/creating-a-local-ssl-certificate is to specify in the CA config section (your [CA_default]) or on the command line the name of an extension section that doesn't actually contain any extensions.

Although if you use v3 certs, in most applications you should have at least BasicConstraints and KeyUsage extensions, and maybe some more, and those usually make more sense to be specified in the CA config rather than in the CSR, because they are mostly not subject-dependent.

Also, most reliers haven't accepted cert signatures using MD5 for about a decade now, and many have more recently stopped accepting signatures using SHA-1 as a result of 'shattered', about which there are numerous other Qs already, and now 'shambles'. Plus assuming your CA key is as strong (large) as your EE key(s) as it should be, neither of those hashes was ever recommended in combination with RSA-2048, whose strength needs at least SHA-224 to match, and nearly everybody (for example all 'real' public CAs) uses SHA-256.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.