4096 密钥长度的 RSA 证书为例,将生成的私钥保存为 ca-rsa.key 文件。openssl genrsa -out ca-rsa.key 4096
ca-rsa.csr,以下命令通过 -subj 指定了证书的基本信息,其中:openssl req -new -key ca-rsa.key -out ca-rsa.csr -subj "/C=US/ST=State/L=City/O=Example Org/OU=Example CA/CN=Example Root CA"
ca-rsa.crt。其中 -extfile 中指定了该证书为 CA 证书。openssl x509 -req -in ca-rsa.csr -out ca-rsa.crt -signkey ca-rsa.key -days 3650 -sha256 -extfile <(printf "basicConstraints=critical,CA:TRUE\\nkeyUsage=critical,keyCertSign,cRLSign\\nsubjectKeyIdentifier=hash\\n")
openssl x509 -in ca-rsa.crt -noout -text | grep -A2 "X509v3 Basic Constraints"
CA:TRUE 则为正确的 CA 证书。参考输出结果如下:X509v3 Basic Constraints: criticalCA:TRUE # 代表该证书为 CA 证书。X509v3 Key Usage: critical
www.example.com 的证书为例,您可以通过以上生成的 CA 证书,开始自签发域名证书:4096 密钥长度的 RSA 证书为例,将生成的私钥保存为 rsa-domain.key 文件。openssl ecparam -name secp384r1 -genkey -noout -out rsa-domain.key
rsa-domain.csr,以下命令通过 -subj 指定了证书的基本信息, 请注意将 CN 字段内容替换为你想签发的域名,本示例中以 www.example.com 为例。openssl req -new -key rsa-domain.key -out rsa-domain.csr -subj "/C=US/ST=State/L=City/O=Example Org/OU=Example CA/CN=www.example.com"
rsa-domain.crt。openssl x509 -req -in rsa-domain.csr -out rsa-domain.crt -CA ca-rsa.crt -CAkey ca-rsa.key -days 3650
openssl verify -CAfile ca-rsa.crt rsa-domain.crt
rsa-domain.crt:OK,则说明该证书签发链路正确。参考如下:rsa-domain.crt: OK
secp384r1 加密算法的 ECC 证书为例,将生成的私钥保存为 ca-ecc.key 文件。openssl ecparam -name secp384r1 -genkey -noout -out ca-ecc.key
ca-ecc.csr,以下命令通过 -subj 指定了证书的基本信息,其中:openssl req -new -key ca-ecc.key -out ca-ecc.csr -subj "/C=US/ST=State/L=City/O=Example Org/OU=Example CA/CN=Example Root CA"
ca-ecc.crt。其中 -extfile 中指定了该证书为 CA 证书。openssl x509 -req -in ca-ecc.csr -out ca-ecc.crt -signkey ca-ecc.key -days 3650 -sha256 -extfile <(printf "basicConstraints=critical,CA:TRUE\\nkeyUsage=critical,keyCertSign,cRLSign\\nsubjectKeyIdentifier=hash\\n")
openssl x509 -in ca-ecc.crt -noout -text | grep -A2 "X509v3 Basic Constraints"
CA:TRUE 则为正确的 CA 证书。参考输出结果如下:X509v3 Basic Constraints: criticalCA:TRUE # 代表该证书为 CA 证书。X509v3 Key Usage: critical
www.example.com 的证书为例,您可以通过以上生成的 CA 证书,开始自签发域名证书:secp384r1 加密算法的 ECC 证书为例,将生成的私钥保存为 ecc-domain.key 文件。openssl ecparam -name secp384r1 -genkey -noout -out ecc-domain.key
ecc-domain.csr,以下命令通过 -subj 指定了证书的基本信息, 请注意将 CN 字段内容替换为你想签发的域名,本示例中以 www.example.com 为例。openssl req -new -key ecc-domain.key -out ecc-domain.csr -subj "/C=US/ST=State/L=City/O=Example Org/OU=Example CA/CN=www.example.com"
ecc-domain.crt。openssl x509 -req -in ecc-domain.csr -out ecc-domain.crt -CA ca-ecc.crt -CAkey ca-ecc.key -days 3650
openssl verify -CAfile ca-ecc.crt ecc-domain.crt
ecc-domain.crt:OK,则说明该证书签发链路正确。ecc-domain.crt: OK
文档反馈