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

相关推荐
特立独行的猫a4 天前
[鸿蒙PC命令行程序移植实战]:交叉编译移植最新openSSL 4.0.0到鸿蒙PC
华为·harmonyos·移植·openssl·交叉编译·鸿蒙pc
十五年专注C++开发7 天前
CMake进阶:vcpkg中OpenSSLConfig.cmake详解
c++·windows·cmake·openssl·跨平台编译
一个平凡而乐于分享的小比特8 天前
OpenSSL 全面解析:从入门到精通
密码学·openssl·隐私安全
mooyuan天天12 天前
万字详解心脏滴血漏洞复现:原理详解+环境搭建+渗透实践(CVE-2014-0160)
openssl·心脏滴血漏洞·cve-2014-0160
bkspiderx17 天前
OpenSSL全解析:从基础原理到交叉编译与实战应用
openssl
ZXF_H1 个月前
C/C++ OpenSSL自适应格式解析证书二进制字节流
c语言·开发语言·c++·openssl
龚建波1 个月前
记录:vcpkg清单模式安装指定版本的curl和OpenSSL
openssl·curl·vcpkg
YouEmbedded1 个月前
解码ARM 开发板 OpenSSL+cURL 交叉编译与 HTTPS 配置
https·openssl·curl
吃西瓜的星星1 个月前
从0开始完成ActiveMQ-cpp在windows_x86平台的编译(从编译openssl开始)
activemq·openssl·c/c++
赖small强2 个月前
【ZeroRange WebRTC】OpenSSL 与 WebRTC:原理、集成与实践指南
webrtc·openssl·x.509·证书验证·tls/dtls