当前位置:网站首页>OpenSSL 自签名证书颁发脚本 —— 筑梦之路
OpenSSL 自签名证书颁发脚本 —— 筑梦之路
2022-07-22 01:57:00 【筑梦之路】
#!/bin/bash
#openssl生成自签名证书脚本
read -p "请输入你的组织:" organization
read -p "请输入你的域名:" FQ
#生成CA证书私钥ca.key
openssl genrsa -out ca.key 4096
#根据ca证书私钥生成CA证书ca.crt
openssl req -x509 -new -nodes -sha512 -days 3650 \
-subj "/C=CN/ST=Beijing/L=Beijing/O=${organization}/OU=${organization}/CN=${FQ}" \
-key ca.key \
-out ca.crt
#生成服务器私钥 yourdomain.com.key
openssl genrsa -out ${FQ}.key 4096
#生成证书签名请求CSR yourdomain.com.csr
openssl req -sha512 -new \
-subj "/C=CN/ST=Beijing/L=Beijing/O=${organization}/OU=${organization}/CN=${FQ}" \
-key ${FQ}.key \
-out ${FQ}.csr
#生成x509 v3扩展文件
cat > v3.ext <<-EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1=${FQ}
DNS.2=${organization}
EOF
#使用该v3.ext文件生成证书 yourdomain.com.crt
openssl x509 -req -sha512 -days 3650 \
-extfile v3.ext \
-CA ca.crt -CAkey ca.key -CAcreateserial \
-in ${FQ}.csr \
-out ${FQ}.crt
#使用说明
echo "a. 将服务器证书${FQ}.crt和密钥${FQ}.key复制到cert或ssl目录下"
mkdir -p /data/cert
cp ${FQ}.crt /data/cert/
cp ${FQ}.key /data/cert/
echo "b. 将服务器证书${FQ}.crt编码格式转换为${FQ}.cert,提供给Docker使用"
openssl x509 -inform PEM -in ${FQ}.crt -out ${FQ}.cert
echo "c. 将服务器证书、密钥和CA文件复制到Harbor主机上的Docker certificate文件夹中"
# 创建证书文件夹
mkdir -p /etc/docker/certs.d/${FQ}
# 拷贝服务器证书
cp ${FQ}.cert /etc/docker/certs.d/${FQ}/
# 拷贝服务器私钥
cp ${FQ}.key /etc/docker/certs.d/${FQ}/
# 拷贝自签的颁发证书机构ca证书
cp ca.crt /etc/docker/certs.d/${FQ}/
systemctl restart docker
边栏推荐
- How to prolong the working life of slip ring
- 2022-07-18 eliminate traversal processing of exists subquery
- Summary of optimistic lock, pessimistic lock and distributed lock
- halcon 使用txt文件格式显示点云
- Worthington peptide synthesis application chymotrypsin scheme
- Worthington cell separation optimization system (including cell separation guide)
- The difference between static variables and global variables
- Test the function of voting
- 分布式链路追踪-skywalking基础
- 怎样可以让导电滑环的信号更好
猜你喜欢
LVGL之事件处理篇
AI首席架构师11-“3D+AI”在智慧体育的应用与拓展
Timed time test
Myocardial xanthase -- characteristics of myocardial xanthase of Clostridium crenatum Worthington
Design of ads multi frequency power amplifier bias network
plt 画图并保存结果
With no performance forecast, BOE is silent at this time?
Graffiti Wi Fi & ble SoC development slide strip (5) -- burning authorization
如何对齐MathType公式和Word文字排版
Simple use of Android kotlin
随机推荐
滑环的分类以及用途
21JVM内存模型(JMM)
shardingjdbc水平分表配置
Distributed link tracking skywalking practice
Worthington cell separation optimization system (including cell separation guide)
For more than 20 years, how has classified protection "kept pace with the times"?
LVGL之事件处理篇
Redis的拓展方案
[independent station operation] Shopify sellers: how to improve the store experience? Two moves are done!
NFC介绍(2)
Redis缓存穿透和雪崩
2022-07-18 Jenkins pipeline use and create your own pipeline
92.(leaflet篇)leaflet态势标绘-进攻方向采集
Worthington 胆碱酯酶,丁酰相关说明书
Summary of optimistic lock, pessimistic lock and distributed lock
Elastase Worthington core enzyme detailed reference
分布式链路追踪-skywalking实战
Waiting insurance compliance 2022 series | what should you know about waiting insurance this year?
MySQL的锁机制:MyISAM 表锁、InnoDB行锁
Release time test