openssl 用法整理 —— 筑梦之路

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

# 生成私钥
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

用法二 生成消息摘要

# 计算SHA256摘要
echo -n "Hello, world!" | openssl dgst -sha256

用法三 加密和解密文件

# 加密文件
openssl enc -aes-256-cbc -salt -in plaintext.txt -out encrypted.txt

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

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

# 生成根证书私钥
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

用法五 生成随机数

# 生成随机数
openssl rand -hex 16

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

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值