openssl 用法整理 —— 筑梦之路

用法一 生成自签名数字证书

bash 复制代码
# 生成私钥
openssl genpkey -algorithm RSA -out private.key

# 生成证书请求
openssl req -new -key private.key -out certificate.csr

# 使用私钥签署证书
openssl x509 -req -days 365 -in certificate.csr -signkey private.key -out certificate.crt

用法二 生成消息摘要

bash 复制代码
# 计算SHA256摘要
echo -n "Hello, world!" | openssl dgst -sha256

用法三 加密和解密文件

bash 复制代码
# 加密文件
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.txt

# 解密文件
openssl enc -aes-256-cbc -d -in encrypted.txt -out decrypted.txt

用法四 创建自签名根证书和证书链

bash 复制代码
# 生成根证书私钥
openssl genpkey -algorithm RSA -out root.key

# 生成根证书请求
openssl req -new -key root.key -out root.csr

# 自签名根证书
openssl x509 -req -days 365 -in root.csr -signkey root.key -out root.crt

# 创建证书链
cat root.crt > chain.crt
cat intermediate.crt >> chain.crt

用法五 生成随机数

bash 复制代码
# 生成随机数
openssl rand -hex 16

https://github.com/pdf2htmlEX/pdf2htmlEX.git

相关推荐
轻松Ai享生活13 小时前
5 节课深入学习Linux Cgroups
linux
christine-rr14 小时前
linux常用命令(4)——压缩命令
linux·服务器·redis
三坛海会大神55514 小时前
LVS与Keepalived详解(二)LVS负载均衡实现实操
linux·负载均衡·lvs
東雪蓮☆14 小时前
深入理解 LVS-DR 模式与 Keepalived 高可用集群
linux·运维·服务器·lvs
乌萨奇也要立志学C++14 小时前
【Linux】进程概念(二):进程查看与 fork 初探
linux·运维·服务器
绿箭柠檬茶16 小时前
Ubuntu 服务器配置转发网络访问
服务器·网络·ubuntu
獭.獭.16 小时前
Linux -- 信号【上】
linux·运维·服务器
hashiqimiya16 小时前
centos配置环境变量jdk
linux·运维·centos
hashiqimiya16 小时前
权限更改centos中系统文件无法创建文件夹,使用命令让普通用户具备操作文件夹
linux
路由侠内网穿透17 小时前
本地部署 GPS 跟踪系统 Traccar 并实现外部访问
运维·服务器·网络·windows·tcp/ip