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

相关推荐
API开发10 天前
苹果芯片macOS安装版Homebrew(亲测) ,一键安装node、python、vscode等,比绿色软件还干净、无污染
vscode·python·docker·nodejs·openssl·brew·homebrew
码农不惑14 天前
Rust使用tokio(二)HTTPS相关
https·rust·web·openssl
liulilittle20 天前
通过高级处理器硬件指令集AES-NI实现AES-256-CFB算法并通过OPENSSL加密验证算法正确性。
linux·服务器·c++·算法·安全·加密·openssl
liulilittle22 天前
OpenSSL 的 AES-NI 支持机制
linux·运维·服务器·算法·加密·openssl·解密
liulilittle22 天前
通过高级处理器硬件指令集AES-NI实现AES-256-CFB算法。
linux·服务器·c++·算法·安全·加密·openssl
花花少年23 天前
Ubuntu系统下交叉编译openssl
openssl·交叉编译
什么名字都被用了2 个月前
编译openssl源码
c++·openssl
toooooop82 个月前
openssl_error_string() 不要依赖错误信息作为逻辑判断
php·openssl
whoarethenext2 个月前
加密认证库openssl初始附带c/c++的使用源码
c语言·网络·c++·openssl
好记忆不如烂笔头abc3 个月前
centos7.9升级OpenSSL 1.1.1
openssl