证书相关之自签名证书制作

参考链接:https://devopscube.com/create-self-signed-certificates-openssl/

1、生成CA私钥和CA证书

# 创建工作目录
mkdir selfCA && cd selfCA 


# 生成CA私钥和根证书
openssl req -x509 -sha256 -days 365 -nodes -newkey rsa:2048 -subj "/CN=ca.qiubo.fun/C=CN/L=Shenzhen" -keyout selfCA.key -out selfCA.crt

# 查看根证书信息
openssl x509 -in selfCA.crt -text -noout

2、创建CSR

# 创建CSR配置文件
openssl genrsa -out server.key 2048

# 创建服务器证书请求CSR
cat > csr.conf <<EOF
[ req ]
default_bits = 2048
prompt = no
default_md = sha256
req_extensions = req_ext
distinguished_name = dn

[ dn ]
C = CN
ST = Guangdong
L = Shenzhen
O = QiuboFun
OU = Lab
CN = 192.168.3.71

[ req_ext ]
subjectAltName = @alt_names

[ alt_names ]
DNS.1 = 192.168.3.71
IP.1 = 192.168.3.71
EOF

# 创建CSR
openssl req -new -key server.key -out server.csr -config csr.conf

4、生成证书

# 创建证书配置文件
cat > cert.conf <<EOF

authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = 192.168.3.71

EOF

# 生成证书
openssl x509 -req \
    -in server.csr \
    -CA selfCA.crt -CAkey selfCA.key \
    -CAcreateserial -out server.pem \
    -days 365 \
    -sha256 -extfile cert.conf
posted @   AmazingQBX  阅读(195)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· 没有源码,如何修改代码逻辑?
· PowerShell开发游戏 · 打蜜蜂
· 在鹅厂做java开发是什么体验
· WPF到Web的无缝过渡:英雄联盟客户端的OpenSilver迁移实战
点击右上角即可分享
微信分享提示