openssl3.2 - 官方demo学习 - test - certs - 001 - Primary root: root-cert

文章目录

    • [openssl3.2 - 官方demo学习 - test - certs - 001 - Primary root: root-cert](#openssl3.2 - 官方demo学习 - test - certs - 001 - Primary root: root-cert)
    • 概述
    • 笔记
    • 备注
    • END

openssl3.2 - 官方demo学习 - test - certs - 001 - Primary root: root-cert

概述

实验前置条件为 openssl3.2 - linux脚本(.sh)调用openssl命令行参数的简单确认方法

笔记

做官方第2个实验时, 才发现, 自己记录的管道文件没有考虑-extfile后面带的管道.

重新修正了openssl的入口日志记录实现, 现在ok了.

命令行 - 原始

openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out root-key.pem

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

openssl x509 -req -sha256 -out root-cert.pem -extfile /dev/fd/63 -signkey root-key.pem -set_serial 1 -days 36525

命令行 - 整理

openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out root-key.pem

openssl req -new -sha256 -key root-key.pem -config config_cfg.txt -out root_req.pem

openssl x509 -req -sha256 -in root_req.pem -out root-cert.pem -extfile extfile_cfg.txt -signkey root-key.pem -set_serial 1 -days 36525

配置文件 - config_cfg.txt

string_mask=utf8only

req

prompt = no

distinguished_name = dn

dn

CN = Root CA

配置文件 - extfile_cfg.txt

basicConstraints = critical,CA:true

keyUsage = keyCertSign,cRLSign

subjectKeyIdentifier = hash

authorityKeyIdentifier = keyid

// --------------------------------------------------------------------------------

命令行实验1

openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out root-key.pem

// --------------------------------------------------------------------------------

功能 - 产生私钥

参数含义 - 产生私钥 - 算法为rsa - 私钥位数2048 - 输出文件 - root-key.pem

// --------------------------------------------------------------------------------

命令行实验2

openssl req -new -sha256 -key root-key.pem -config config_cfg.txt -out root_req.pem

// --------------------------------------------------------------------------------

功能 - 生成证书请求文件

参数含义 - 请求新的证书请求文件 - 摘要算法为sha256 - 私钥为 root-key.pem

配置文件为 config_cfg.txt 输出文件为root_req.pem

// --------------------------------------------------------------------------------

命令行实验3

openssl x509 -req -sha256 -in root_req.pem -out root-cert.pem -extfile extfile_cfg.txt -signkey root-key.pem -set_serial 1 -days 36525

// --------------------------------------------------------------------------------

功能 - 生成证书

参数含义- 进行X509请求 - 摘要算法=sha256 输入的证书请求文件为root_req.pem

输出的证书名称=root-cert.pem 扩展配置文件=extfile_cfg.txt

签名密钥=root-key.pem 证书序列号=1 正式有效天数=36525

备注

官方原版的脚本调用命令行的实现, 如果改为落地的配置文件的调用, 需要改命令行的参数.

生成证书请求文件时, 如果不加 -out 选项, 证书请求文件是不落地的, 只是打印到stdout.

生成证书时, 需要证书请求文件. 需要加 -in 参数, 后面带着证书请求文件的名称.

这说明, 即使官方提供了非正式的例子(/test/certs/setup.sh), 如果自己不实践, 也不是拿过来就能用的.

END

相关推荐
Lsetea1 天前
curl用IP测试HTTPS报证书不匹配:--resolve与Host头别混用
linux·https·ssl证书·openssl·curl
Lsetea3 天前
OpenSSL verify报unable to get issuer certificate:error 2与partial_chain排查
linux·https·ssl证书·openssl·证书链
Lsetea3 天前
OpenSSL verify报unhandled critical extension:error 34与关键扩展排查
运维·https·ssl证书·openssl·证书链
Lsetea4 天前
OpenSSL verify报CA certificate key too weak:auth_level与弱密钥链排查
运维·https·ssl证书·openssl·证书链
Lsetea6 天前
OpenSSL verify报invalid CA certificate:basicConstraints与keyCertSign排查
运维·https·ssl证书·openssl·证书链
Lsetea7 天前
OpenSSL verify报error 62:证书主机名不匹配与-verify_hostname排查
运维·https·ssl证书·openssl·san
Lsetea7 天前
OpenSSL verify报certificate signature failure:error 7与证书签名排查
运维·https·ssl证书·openssl·证书链
Lsetea8 天前
curl指定CA目录仍报证书不受信任:--capath与OpenSSL rehash排查
运维·https·ssl·openssl·curl
Lsetea9 天前
OpenSSL报path length constraint exceeded:CA层级与pathlen排查
运维·https·ssl证书·openssl·证书链
Lsetea9 天前
OpenSSL s_client退出码为0却证书验证失败:严格校验与Shell管道排查
https·shell·ssl证书·openssl·tls