问题原文
原帖链接 · d.lanza38 · CC BY-SA 4.0
I'm following similar steps as this answer to create a local CA.
Despite setting the default_days option to 1825 (days) in my config file, the resulting CA certificate is always set to expire 30 days after creation.
I'm confirming this by viewing the resulting PEM file with
openssl x509 -in ./cacert.pem -text -noout
Here is the config file I'm using to create the CA certificate:
HOME = .
RANDFILE = $ENV::HOME/.rnd
####################################################################
[ ca ]
default_ca = CA_default # The default ca section
[ CA_default ]
default_days = 1825 # how long to certify for
default_crl_days = 30 # how long before next CRL
default_md = sha256 # use public key default MD
preserve = no # keep passed DN ordering
x509_extensions = ca_extensions # The extensions to add to the cert
email_in_dn = no # Don't concat the email in the DN
copy_extensions = copy # Required to copy SANs from CSR to cert
base_dir = ./CA
certificate = $base_dir/cacert.pem # The CA certifcate
private_key = $base_dir/private/cakey.pem # The CA private key
new_certs_dir = $base_dir/newcerts # Location for new certs after signing
database = $base_dir/index.txt # Database index file
serial = $base_dir/serial # The current serial number
unique_subject = no # Set to 'no' to allow creation of
# several certificates with same subject.
####################################################################
[ req ]
default_bits = 4096
default_keyfile = cakey.pem
distinguished_name = ca_distinguished_name
x509_extensions = ca_extensions
string_mask = utf8only
####################################################################
[ ca_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = US
stateOrProvinceName = State or Province Name (full name)
stateOrProvinceName_default = CA
localityName = Locality Name (eg, city)
localityName_default = Bakersfield
organizationName = Organization Name (eg, company)
organizationName_default = Some Company
organizationalUnitName = Organizational Unit (eg, division)
organizationalUnitName_default = Some Org Unit
commonName = Common Name (e.g. server FQDN or YOUR name)
commonName_default = some-local-CA
emailAddress = Email Address
emailAddress_default = [email omitted]
####################################################################
[ ca_extensions ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always, issuer
basicConstraints = critical, CA:true
keyUsage = keyCertSign, cRLSign
####################################################################
[ signing_policy ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
####################################################################
[ signing_req ]
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer
basicConstraints = CA:FALSE
keyUsage = digitalSignature, keyEncipherment
I then create the local CA with this command (same directory):
openssl req -x509 -config ./openssl-ca.cnf -newkey rsa:4096 -sha256 -nodes -out cacert.pem -outform PEM
I tried setting the default_crl_days option to something other than 30 and it didn't seem to have any effect.
How do I specify the expiration date (or number of days until expiration) for my local CA?
已采纳解答
原帖链接 · slm · CC BY-SA 4.0
With the setup I have for generating a CA and CA-INT I get the following for my validity dates:
Validity
Not Before: Jan 28 03:28:40 2018 GMT
Not After : Jan 23 03:28:40 2038 GMT
What I came to discover is that I could only get this to work by passing it in to openssl directly via the -days switch.
For example:
openssl req -config $topDir/openssl.cnf \
-key $ca_key_file \
-new -x509 -days 7300 -sha256 -extensions v3_ca \
-out $ca_cert_file -passin pass:casecret \
-subj "/C=US/ST=NC/L=Raleigh/O=APPS Security/OU=APPS/CN=APPS CA"
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
