OpenSSL生成CA自签名根证书和颁发证书和证书提取
CA根证书 生成流程
第一步 生成CA证书私钥
1、#生成ca私钥 (.key 和 pem 只是格式不一样)
openssl genrsa -aes128 -passout pass:Test@2022 -out ca_private.key 2048 # 生成aes128位编码的 密码为Test@2022 2048位的 key 文件 (带密码 、加密格式 aes、des 3des等)
openssl genrsa -out ca_private.key 2048 #生成 2048位的 key 文件 (不带密码,加密格式 等)
#也可生成 ca_private.pem 文件,将后缀.key 变更为.pem
openssl genrsa -aes128 -passout pass:Test@2022 -out ca_private.pem 2048 # 生成aes128位编码的 密码为Test@2022 2048位的 key 文件 (带密码 、加密格式 aes、des 3des等)
openssl genrsa -out ca_private.pem 2048 #生成 2048位的 key 文件 (不带密码,加密格式 等)
第二步 生成CA证书请求文件 (格式 同第一步)
2、# 有效期20年:
openssl req -new -key ca_private.key -passin pass:Test@2022 -out ca_req.csr -days 7300
# 也可以 将后缀.key 变更为.pem (注意目录,文件放在哪个目录下,一会用的到,别找不到路径)
openssl req -new -key ca/ca_private.pem -out ca/ca_req.csr -days 7300
# 填写 国家、机构、密码等,按实际情况填写即可
第三步、生成CA根证书
3、CA根证书 (注意目录,文件放在哪个目录下,一会用的到,别找不到路径)
openssl x509 -req -in ca_req.csr -signkey ca_private.key -out ca_root.crt -days 7300 -passin pass:Test@2022
# 也可以 将后缀.key 变更为.pem
openssl x509 -req -in ca_req.csr -signkey ca_private.pem -out ca_root.pem -days 7300 #不带密码
自此 根证书文件生成完毕 注:接下来服务器证书要根据 以上证书 来生成
第四步、服务器证书生成 与根节点服务器证书类似,只是生成 服务器证书的第三部要依赖 生成的 ca 根证书
4、生成服务器私钥
openssl genrsa -aes128 -passout pass:Test@2022 -out server_private.key 2048 # 带秘钥 带加密方式 等同 ca 第一步
# 可以 去掉密码 去掉加密 方式
openssl genrsa -out server_private.key 2048
第五步、生成服务端的待签名证书
5、有效期10年:
openssl req -new -key server_private.key -passin pass:Test@2022 -out server_req.csr -days 3650
无密码可以去掉密码部分
openssl req -new -key server_private.pem -out server_req.csr -days 3650
第六步、使用CA根证书对服务端证书签名
6、
openssl x509 -req -in server_req.csr -days 3650 -CAkey ca_private.key -CA ca_root.crt -CAcreateserial -out server.crt
pem 版本
openssl x509 -req -in server_req.csr -days 3650 -CAkey ca_private.pem -CA ca_root.pem -CAcreateserial -out server.crt
注 5、6步可以合成:
$>openssl x509 -req -in xxx/xxx-req.csr -out xxx/xxx-cert.pem -signkey xxx/xxx-key.pem -CA ca/ca-cert.pem -CAkey ca/root-key.pem -CAcreateserial -days 3650 ##签署服务器证书
Signature ok
subject=/C=CN/ST=Zhejiang/L=Hangzhou/O=xxx
Getting Private key
Getting CA Private Key
第七步、证书提取
7、
$>openssl pkcs12 -export -clcerts -in xxx/xxx-cert.pem -inkey xxx/xxx-key.pem -out xxx/xxx.pfx #这个是平台的私钥
Enter Export Password:123456
Verifying - Enter Export Password:123456
$>openssl rsa -in xxx-key.pem -pubout -out xxx-pubkey.pem #提取公钥,这个是平台的公钥
writing RSA key
双横线上边 和 下边 流程基本一样,上边为理解后 自己总结,下边为快速 生成步骤
=========================================================================
1. 生成CA证书
$>mkdir ca
$>openssl genrsa -out ca/root-key.pem 2048 ##创建根证书私钥
$>openssl req -new -out ca/ca-req.csr -key ca/root-key.pem #创建证书请求
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:ZheJiang
Locality Name (eg, city) []:Hangzhou
Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxx
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:
$>openssl x509 -req -in ca/ca-req.csr -out ca/ca-cert.pem -signkey ca/root-key.pem -days 3650 #自签署根证书
Signature ok
subject=/C=CN/ST=ZheJiang/L=Hangzhou/O=xxx
Getting Private key
$>openssl pkcs12 -export -clcerts -in ca/ca-cert.pem -inkey ca/root-key.pem -out ca/root.pfx #导出这PKCS12格式的证书
Enter Export Password:123456
Verifying - Enter Export Password:123456
2. 创建服务器证书
$>mkdir xxx
$>openssl genrsa -out xxx/xxx-key.pem 2048 ##创建私钥
$>openssl req -new -out xxx/xxx-req.csr -key xxx/xxx-key.pem ##创建证书请求
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Zhejiang
Locality Name (eg, city) []:Hangzhou
Organization Name (eg, company) [Internet Widgits Pty Ltd]:xxx
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456
An optional company name []:
$>openssl x509 -req -in xxx/xxx-req.csr -out xxx/xxx-cert.pem -signkey xxx/xxx-key.pem -CA ca/ca-cert.pem -CAkey ca/root-key.pem -CAcreateserial -days 3650 ##签署服务器证书
Signature ok
subject=/C=CN/ST=Zhejiang/L=Hangzhou/O=xxx
Getting Private key
Getting CA Private Key
$>openssl pkcs12 -export -clcerts -in xxx/xxx-cert.pem -inkey xxx/xxx-key.pem -out xxx/xxx.pfx #这个是平台的私钥
Enter Export Password:123456
Verifying - Enter Export Password:123456
$>openssl rsa -in xxx-key.pem -pubout -out xxx-pubkey.pem #提取公钥,这个是平台的公钥,发给合作方侧
writing RSA key
==================================================================================================================================================
提取:cer证书公钥:
提取命令:
openssl x509 -in XX.cer -pubkey -noout > XX.pem
如果提示没有这个命令 -noout ,去掉它即可
下面这部分就是 要提取的公钥
参考链接:https://blog.csdn.net/qq_44734154/article/details/126167945
OpenSSL生成CA自签名根证书和颁发证书和证书提取相关推荐
- Apache OpenSSL生成CA证书使用
最近在学习SSL协议,这次是基于Apache服务器自带的openssl来实现的 TLS:传输层安全协议 SSL:安全套接字层 KEY:私钥 CSR:证书签名请求,即公钥,生成证书时需要将此提交给证书机 ...
- Linux openssl 搭建CA、签名证书
目录 前言 配置CA 安装openssl 修改 openssl 配置文件 创建所需要的文件 创建CA KEY 创建CA 证书 创建证书 生成密钥 生成签名请求文件 签名证书请求文件 自签名证书 创建 ...
- 使用openssl生成CA、server、client私钥和证书(证书包括公钥)
参考:SSL证书制作并使用NodeJs进行HTTPS认证配置 - 苍青浪 - 博客园 1. 生成CA证书及私钥: 1)生成一个私钥为ca-key.pem openssl genrsa -out ca- ...
- win64使用openssl生成ca证书
一.准备工作: 1. 下载win64的Openssl,可到http://slproweb.com/products/Win32OpenSSL.html下载,这里下载1.0.1j版本.同时在该地址下载V ...
- IIS 使用OpenSSL 生成的自签名证书,然后使用SingalR 客户端访问Https 站点通信
使用SignalR 的客户端去发送消息给使用 https 部署的站点,官方文档目前并没有详细的教程,所以在此记录下步骤: 使用管理员身份打开cmd 窗口,选择一个整数保存文件夹的地址,切换到对应的文件 ...
- 24、OpenSSL生成CA证书及终端用户证书
1.准备ca.conf配置文件 内容如下 [ req ] default_bits = 4096 distinguished_name = req_distinguished_name[ ...
- windows server 证书的颁发与IIS证书的使用
最近工作业务要是用服务器证书验证,在这里记录下一. 1.添加服务器角色 [证书服务] 2.一路下一步直到证书服务安装完成; 3.选择圈选中的服务器证书 4.点击[创建证书申请] 5.填写信息 6.下一 ...
- nginx反向代理cas-server之2:生成证书,centOS下使用openssl生成CA证书(根证书、server证书、client证书)...
前些天搭好了cas系统,这几天一致再搞nginx和cas的反向代理,一直不成功,但是走http还是测试通过的,最终确定是ssl认证证书这一块的问题,原本我在cas服务端里的tomcat已经配置了证书, ...
- 使用OpenSSL生成自签名证书和格式转换
OpenSSL安装:https://blog.csdn.net/qq_44734154/article/details/125995475 一.生成证书私钥 genrsa 介绍:https://www ...
最新文章
- 顺序表-顺序表表示集合-差集(for + while ,不断遍历)
- Redis 性能问题分析
- Docker学习笔记之二,基于Dockerfile搭建JAVA Tomcat运行环境
- MERGE INTO
- 2016年全国计算机技术与软件,2016年的上半年的全国计算机技术与软件专业技术资格(水平)考.doc...
- drupal ajax 分页,在drupal中使用Ajax时要保持一个404
- Android开发笔记(一百六十)休眠模式下的定时器控制
- Saltstack 安装应用笔记一
- X window 概念及原理图
- 3D MAX插件大全介绍
- 潇洒老师教你注塑模具使用顶针油需要注意的问题
- html embed页面无法播放视频,embed标签什么意思 手机无法播放网页上embed标签的视频...
- js距离单位换算_1等于多少公里
- 为什么说JCLGMP必将带来更实实在在的就学等方面权益?
- 淘宝页面详情采集API调用展示(APP端商品详情)
- 第二部分 太阳能预测(半经验模型)
- R语言之管道符的使用和学习
- WebRTC Trickle ICE 策略
- CA 认证过程及 https 实现方法
- android电视识别多区u盘,【当贝市场】电视无法识别U盘APK文件终极方法