我具有包含这些命令的自签名证书链,并在Apache服务器上对其进行了配置
但是当我尝试openssl s_client -showcerts -servername server -connect my-host.local:443 -CAfile all.crt
我从openssl Verify return code: 24 (invalid CA certificate)
收到错误
用于生成证书的命令或配置文件是否存在问题?
# self signed root cert
openssl genrsa -aes256 -out ca.key 4096
openssl req -new -x509 -days 3000 -key ca.key -out ca.crt -config ca.conf
# intermediate cert signed with the root cert
openssl genrsa -aes256 -out int.key 4096
openssl req -new -key int.key -out int.csr -config int.conf
openssl x509 -req -days 3000 -in int.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out int.crt
# leaf cert signed with the intermediate cert
openssl genrsa -aes256 -out leaf.key 4096
openssl req -new -key leaf.key -out leaf.csr -config leaf.conf
openssl x509 -req -days 3000 -in leaf.csr -CA int.crt -CAkey int.key -set_serial 01 -out leaf.crt
cat ca.crt int.crt leaf.crt > all.crt
ca.conf
[req]
专有名称= req_distinguished_name
x509_extensions = v3_ca
dirstring_type = nobmp
[req_distinguished_name]
commonName =常用名(例如,您的姓名)
commonName_default =根
[v3_ca]
keyUsage = critical,keyCertSign
subjectKeyIdentifier =哈希
AuthorityKeyIdentifier = keyid:总是,发出者:总是
basicConstraints = critical,CA:TRUE,pathlen:1
extendedKeyUsage = serverAuthint.conf
[req]
专有名称= req_distinguished_name
x509_extensions = ext
[req_distinguished_name]
commonName =常用名(例如,您的姓名)
commonName_default = int
[ext]
keyUsage = critical,keyCertSign
subjectKeyIdentifier =哈希
AuthorityKeyIdentifier = keyid:总是,发出者:总是
basicConstraints = CA:TRUE,pathlen:0
extendedKeyUsage = serverAuthleaf.conf
[req]
专有名称= req_distinguished_name
dirstring_type = nobmp
[req_distinguished_name]
commonName =常用名(例如,您的姓名)
commonName_default =叶子
答案 0 :(得分:2)
CA根证书has to be marked as belonging to a CA:
CA证书必须包括CA的basicConstraints值 字段设置为TRUE。最终用户证书必须将CA设置为FALSE 或完全排除扩展名。某些软件可能需要 包含将最终实体的CA设置为FALSE的basicConstraints 证书。
这是通过基本约束标准扩展来完成的。要检查您的根证书是否设置了CA
属性,请运行openssl x509 -text -noout -in ca.crt
并在输出中查找CA:True
。请注意,OpenSSL实际上会let you sign other certs with a non-CA root cert(或至少曾经使用过),但是对此类证书的验证将失败(因为CA检查将失败)。
使用您的配置文件,只需在命令中包括-extensions v3_ca
即可生成根证书,就足够了:
openssl req -new -x509 -extensions v3_ca -days 3000 -key ca.key -out ca.crt -config ca.conf -extfile ca.conf