Create a directory to contain everything
touch certindex
echo 1000 > certserial
echo 1000 > crlnumber
vi ca.conf
[ ca ]
default_ca = myca
[ crl_ext ]
issuerAltName=issuer:copy
authorityKeyIdentifier=keyid:always
[ myca ]
dir = ./
new_certs_dir = $dir
unique_subject = no
certificate = $dir/rootca.crt
database = $dir/certindex
private_key = $dir/rootca.key
serial = $dir/certserial
default_days = 730
default_md = sha256
policy = myca_policy
x509_extensions = myca_extensions
crlnumber = $dir/crlnumber
default_crl_days = 730
[ myca_policy ]
commonName = supplied
stateOrProvinceName = supplied
countryName = optional
emailAddress = optional
organizationName = supplied
organizationalUnitName = optional
[ myca_extensions ]
basicConstraints = critical,CA:TRUE
keyUsage = critical,any
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
keyUsage = digitalSignature,keyEncipherment,cRLSign,keyCertSign
extendedKeyUsage = serverAuth
crlDistributionPoints = @crl_section
subjectAltName = @alt_names
authorityInfoAccess = @ocsp_section
[ v3_ca ]
basicConstraints = critical,CA:TRUE,pathlen:0
keyUsage = critical,any
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer
keyUsage = digitalSignature,keyEncipherment,cRLSign,keyCertSign
extendedKeyUsage = serverAuth
crlDistributionPoints = @crl_section
subjectAltName = @alt_names
authorityInfoAccess = @ocsp_section
[alt_names]
DNS.0 = Sparkling Intermidiate CA 1
DNS.1 = Sparkling CA Intermidiate 1
[crl_section]
URI.0 = http://pki.sparklingca.com/SparklingRoot.crl
URI.1 = http://pki.backup.com/SparklingRoot.crl
[ocsp_section]
caIssuers;URI.0 = http://pki.sparklingca.com/SparklingRoot.crt
caIssuers;URI.1 = http://pki.backup.com/SparklingRoot.crt
OCSP;URI.0 = http://pki.sparklingca.com/ocsp/
OCSP;URI.1 = http://pki.backup.com/ocsp
openssl genrsa -out rootca.key 8192
openssl req -sha256 -new -x509 -days 3650 -key rootca.key -out rootca.crt
Then fill in required info
openssl genrsa -out interca1.key 8192
openssl req -sha256 -new -key interca1.key -out interca1.csr
Then fill in required info. Skip challenge password and optional company name
openssl ca -batch -config ca.conf -notext -in interca1.csr -out interca1.crt
mkdir certs
openssl genrsa -out certs/example.com.key 4096
openssl req -new -sha256 -key certs/example.com.key -out certs/example.com.csr
Fill in required info. Skip challenge password and optional company name
openssl ca -batch -config ca.conf -notext -in certs/example.com.csr -out certs/example.com.crt
cat rootca.crt interca1.crt > certs/example.com.chain
Send the following files to whoever requested the certificate
- certs/example.com.crt
- certs/example.com.key
- certs/example.com.chain
openssl x509 -in example.com.crt -text -noout | less
As I see it, according to these instructions, I have signed a user certificate not with an intermediate certificate, but with a CA
In order to honestly sign a user certificate with an intermediate one, you need to add this segment to the config.:
And instead of
openssl ca -batch -config ca.conf -notext -in certs/example.com.csr -out certs/example.com.crt
run
openssl x509 -req -days 365 -in certs/example.com.csr -CA interca1.crt -CAkey interca1.key -CAcreateserial -out certs/example.com.crt -extfile ca.conf -extensions v3_req
It would be more correct.:
Maybe it can be made more beautiful somehow, but I don't care.
UPD: My openssl version: