openssl3.2/test/certs – 015 – Primary intermediate ca: ca-cert

文章目录

    • openssl3.2/test/certs - 015 - Primary intermediate ca: ca-cert
    • 概述
    • 笔记
    • END

openssl3.2/test/certs - 015 - Primary intermediate ca: ca-cert

概述

openssl3.2 - 官方demo学习 - test - certs

笔记

这个例子有不同的地方, 发证书时, 指定了CA.
看实验注释, 是主一级CA来发证书.

file my_openssl_linux_log_doc_015.txt

ote openssl3.2/test/certs - 015 - Primary intermediate ca: ca-cert

// ----------------------------------------------------------------------
// 官方原始脚本
// ----------------------------------------------------------------------
// openssl3.2/test/certs - 015 - Primary intermediate ca: ca-cert
./mkcert.sh genca “CA” ca-key ca-cert root-key root-cert

// ----------------------------------------------------------------------
// openssl 命令行参数整理/分析
// ----------------------------------------------------------------------
// cmd1
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out ca-key.pem

// cmd2
// config file = config_cmd2.txt
string_mask=utf8only
[req]
prompt = no
distinguished_name = dn
[dn]
CN = CA

openssl req -new -sha256 -key ca-key.pem -config config_cmd2.txt -out ca-key-req.pem

// cmd3
// config file = extfile_cmd3.txt
basicConstraints = critical,CA:true
keyUsage = keyCertSign,cRLSign
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid

// root-cert.pem, root-key.pem 是001实验产生的
// 证书和私钥必须匹配, 否则执行报错
// 这张证书产生时, 不仅用到了证书申请文件, 而且指定了CA证书和私钥. 这种情况用于CA根据证书申请文件发布证书.
openssl x509 -req -sha256 -out ca-cert.pem -extfile extfile_cmd3.txt -CA root-cert.pem -CAkey root-key.pem -set_serial 2 -days 36525 -in ca-key-req.pem

// ----------------------------------------------------------------------
// openssl 原始日志
// ----------------------------------------------------------------------
// cmd1
openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out ca-key.pem

// cmd2
openssl req -new -sha256 -key ca-key.pem -config /dev/fd/63

-config /dev/fd/63 => /home/lostspeed/openssl/openssl-3.2.0_debian/test/certs/my_openssl_linux_log.txt

string_mask=utf8only
[req]
prompt = no
distinguished_name = dn
[dn]
CN = CA

// cmd3
openssl x509 -req -sha256 -out ca-cert.pem -extfile /dev/fd/63 -CA root-cert.pem -CAkey root-key.pem -set_serial 2 -days 36525

-extfile /dev/fd/63 => /home/lostspeed/openssl/openssl-3.2.0_debian/test/certs/my_openssl_linux_log.txt

basicConstraints = critical,CA:true
keyUsage = keyCertSign,cRLSign
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid

END