我知道如何使用 openssl
签署 CSR,但结果证书是 x509 v1 而不是 v3。
我正在使用以下命令:
x509 -req -days 365 -in myCSR.csr -CA myCA.crt -CAkey myCA.key -CAcreateserial -out userCertificate.crt
我已经搜索过,但是没有找到解决办法。还有其他编程方法可以实现吗?
我知道如何使用 openssl
签署 CSR,但结果证书是 x509 v1 而不是 v3。
我正在使用以下命令:
x509 -req -days 365 -in myCSR.csr -CA myCA.crt -CAkey myCA.key -CAcreateserial -out userCertificate.crt
我已经搜索过,但是没有找到解决办法。还有其他编程方法可以实现吗?
您需要指定一个扩展文件。
例如:
openssl x509 -days 365 -in myCSR.csr -extfile v3.ext -CA myCA.crt -CAkey myCA.key -CAcreateserial -out userCertificate.crt
扩展文件(v3.ext)的格式可能如下所示:
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
openssl x509 -req -in myCSR.csr -extfile v3.ext -CA myCA.crt -CAkey myCA.key -CAcreateserial -out userCertificate.crt -days 365
(由于我没有足够的声望来发表评论,所以必须作为新答案提供。)
subjectAltName = DNS:hostname,IP:192.168.7.1
。您可以省略DNS或IP部分,但不要忘记删除逗号。更多信息请参见此处。 - Aleksandar