SSL证书的生成方法
在Linux下,我们进行下面的操作前都须确认已安装OpenSSL软件包。
1.创建根证书密钥文件root.key:
[root@mrlapulga:/etc/pki/CA/private]#openssl genrsa -des3 -out root.key 1024
Generating RSA private key, 1024 bit long modulus
...............................................................++++++
..........++++++
e is 65537 (0x10001)
Enter pass phrase for root.key: <--输入一个密码
Verifying - Enter pass phrase for root.key: <--再次输入密码
2.创建根证书的申请文件root.csr:
[root@mrlapulga:/etc/pki/CA]#openssl req -new -key root.key -out root.csr
Enter pass phrase for root.key: <--输入前面创建的密码
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) [XX]:CN <--输入国家名
State or Province Name (full name) []:BeiJing <--输入省份
Locality Name (eg, city) [Default City]:haidian <--输入城市名
Organization Name (eg, company) [Default Company Ltd]:mrlapulga <--输入公司名
Organizational Unit Name (eg, section) []: <--可不输入
Common Name (eg, your name or your server's hostname) []: <--可不输入
Email Address []:mrlapulga@126.com <--输入邮件地址
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <--可不输入
An optional company name []: <--可不输入
3.创建一个为期十年的根证书root.crt:
[root@mrlapulga:/etc/pki/CA]#openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey private/root.key -in root.csr -out root.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=haidian/O=mrlapulga/emailAddress=mrlapulga@126.com
Getting Private key
Enter pass phrase for private/root.key: <--输入之前创建的密码
4.创建服务器证书密钥server.key:
[root@mrlapulga:/etc/pki/CA/private]#openssl genrsa -des3 -out server.key 1024
Generating RSA private key, 2014 bit long modulus
............+++
................................................+++
e is 65537 (0x10001)
Enter pass phrase for server.key: <--输入一个密码
Verifying - Enter pass phrase for server.key: <--再次输入密码
5.创建服务器证书的申请文件server.csr:
[root@mrlapulga:/etc/pki/CA]#openssl req -new -key private/server.key -out server.csr
Enter pass phrase for private/server.key: <--输入前面创建的密码
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) [XX]:CN <--输入国家名
State or Province Name (full name) []:BeiJing <--输入省份
Locality Name (eg, city) [Default City]:haidian <--输入城市名
Organization Name (eg, company) [Default Company Ltd]:mrlapulga <--输入公司名
Organizational Unit Name (eg, section) []: <--可不输入
Common Name (eg, your name or your server's hostname) []: <--可不输入
Email Address []:mrlapulga@126.com <--输入邮件地址
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <--可不输入
An optional company name []: <--可不输入
6.创建一个为期一年的服务器证书server.crt:
[root@mrlapulga:/etc/pki/CA]#openssl x509 -req -days 365 -sha1 -extensions v3_req -CA root.crt -CAkey private/root.key -CAcreateserial -in server.csr -out server.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=haidian/O=mrlapulga/emailAddress=mrlapulga@126.com
Getting CA Private Key
Enter pass phrase for private/root.key: <--输入之前创建的密码
7.创建客户端证书密钥文件client.key:
[root@mrlapulga:/etc/pki/CA/private]#openssl genrsa -des3 -out client.key 1024
Generating RSA private key, 1024 bit long modulus
..............................++++++
..................................................++++++
e is 65537 (0x10001)
Enter pass phrase for client.key: <--输入一个密码
Verifying - Enter pass phrase for client.key: <--再次输入密码
8.创建客户端证书的申请文件client.csr:
[root@mrlapulga:/etc/pki/CA]#openssl req -new -key private/client.key -out client.csr
Enter pass phrase for private/client.key: <--输入前面创建的密码
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) [XX]:CN <--输入国家名
State or Province Name (full name) []:BeiJing <--输入省份
Locality Name (eg, city) [Default City]:haidian <--输入城市名
Organization Name (eg, company) [Default Company Ltd]:mrlapulga <--输入公司名
Organizational Unit Name (eg, section) []: <--可不输入
Common Name (eg, your name or your server's hostname) []: <--可不输入
Email Address []:mrlapulga@126.com <--输入邮件地址
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: <--可不输入
An optional company name []: <--可不输入
9.创建一个有效期为一年的客户端证书client.crt:
[root@mrlapulga:/etc/pki/CA]#openssl x509 -req -days 365 -sha1 -extensions v3_req -CA root.crt -CAkey private/root.key -CAcreateserial -in client.csr -out client.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=haidian/O=mrlapulga/emailAddress=mrlapulga@126.com
Getting CA Private Key
Enter pass phrase for private/root.key: <--输入之前创建的密码
10.现在可将客户端证书文件client.crt和客户端证书密钥文件client.key合并为客户端的client.pfx安装包文件:
[root@mrlapulga:/etc/pki/CA]#openssl pkcs12 -export -in client.crt -inkey private/client.key -out client.pfx
Enter pass phrase for private/client.key: <--输入之前创建的密码
Enter Export Password: <--创建一个新密码
Verifying - Enter Export Password: <--确认密码
client.pfx是配置双向SSL时需要客户端安装的证书文件。
SSL证书的生成方法的更多相关文章
- Https系列之一:https的简单介绍及SSL证书的生成
Https系列会在下面几篇文章中分别作介绍: 一:https的简单介绍及SSL证书的生成二:https的SSL证书在服务器端的部署,基于tomcat,spring boot三:让服务器同时支持http ...
- SSL证书的生成
openssl工具下载路径:链接:https://pan.baidu.com/s/1o0-s8OplHZt55Cio2HmjVA 密码:u759 1.使用openssl工具生成一个RSA秘钥 ...
- 让GIt忽略SSL证书错误的方法
当你通过HTTPS访问Git远程仓库,如果服务器的SSL证书未经过第三方机构签署,那么Git就会报错.这是十分合理的设计,毕竟未知的没有签署过的证书意味着很大安全风险.但是,如果你正好在架设Git服务 ...
- Nginx配置SSL证书部署HTTPS方法
1.申请域名,绑定服务器ip(我申请的是阿里云服务器,以下就此为例) 2.可以在阿里云上免费申请SSL证书(下载证书,后续会用到) 3.在服务器中配置证书 在服务器上安装Nginx 将下载好的证书上传 ...
- TortoiseGit 访问https远程仓库,上报SSL证书错误解决方法
报错 在使用TortoiseGit时,clone自己搭建的gitlab报如错SSL certificate problem: self signed certificate 原因:自行搭建的gitla ...
- CentOS 7.2 下nginx SSL证书部署的方法(使用crt以及key 配置)
转自:https://www.jb51.net/article/107350.htm 环境 系统环境:CentOS6.7 nginx version: nginx/1.8.1 证书 ? 1 2 3 # ...
- 生成ssl证书文件
网上关于生成SSL证书文件的方法有很多,但我查了几个,发现有或多或少的错误,如下我图文并茂的展示,亲测无任何问题,分享给大家,谢谢. 1.创建根证书密钥文件(自己做CA)root.key openss ...
- 如何在 CentOS 7 上生成 SSL 证书为 Nginx 加密
本文首发:开发指南:如何在 CentOS 7 上安装 Nginx Let’s Encrypt 是由 Internet Security Research Group (ISRG) 开发的一个自由.自动 ...
- http跳转https方法:百度云如何让http自动跳转到https【免费SSL证书使用FAQ】
之前的一篇文章已经给大家提供了免费SSL证书的申请方法,这一篇文章是告诉大家在使用免费的SSL证书时可能会遇到的问题[怎么让http自动跳转到https以及http与https同时使用]的解决方法. ...
随机推荐
- 关注云端搜索技术:elasticsearch,nutch,hadoop,nosql,mongodb,hbase,cassandra 及Hadoop优化
http://www.searchtech.pro/ Hadoop添加或调整的参数: 一.hadoop-env.sh1.hadoop的heapsize的设置,默认1000 # The maximum ...
- 微信公众平台开发-access_token获取及应用(含源码)
微信公众平台开发-access_token获取及应用(含源码)作者: 孟祥磊-<微信公众平台开发实例教程> 很多系统中都有access_token参数,对于微信公众平台的access_to ...
- 自定义view(二)
这里是自定义view(二),上一篇关于自定义view的一些基本知识,比如说自定义view的步骤.会涉及到哪些函数以及如何实现自定义属性,同时实现了一个很基础的自定义控件,一个自定义的计时器,需要看的人 ...
- Express4.x动态的销毁或者替换中间件(app.unuse)
需求描述 expres4.x托管静态资源时以中间件的方式将server-static挂载到app上,正常的使用没有问题,但是有时候我们需要动态的托管一些静态资源,也就是静态资源的目录不确定的时候该怎么 ...
- Vuex 学习总结
好在之前接触过 flux,对于理解 vuex 还是很有帮助的.react 学到一半,后来因为太忙,就放弃了,现在也差不多都忘记了.不过感觉 vuex 还是跟 flux 还是有点区别的. 对于很多新手来 ...
- jQuery测验题
1.在div元素中,包含了一个<span>元素,通过has选择器获取<div>元素中的<span>元素的语法是? 提示使用has() $("div:has ...
- wemall app商城源码Android之支付宝通知处理类
wemall-mobile是基于WeMall的Android app商城,只需要在原商城目录下上传接口文件即可完成服务端的配置,客户端可定制修改.本文分享wemall app商城源码Android之处 ...
- Kubernetes 1.5安装
Kubernetes从1.3开始引入kubeadm来试图简化其复杂的安装.但kubeadm至今仍不稳定,而且我个人觉得kubeadm反而麻烦,还不如直接用脚本或者其他自动化工具来安装来的利索.关于ku ...
- 1687: [Usaco2005 Open]Navigating the City 城市交通
1687: [Usaco2005 Open]Navigating the City 城市交通 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 94 Sol ...
- Java的内存机制详解
Java把内存分为两种:一种是栈内存,另一种是堆内存.在函数中定义的一些基本类型的变量和对象的引用变量都是在函数的栈内存中分配,当在一段代码块定义一个变量时,Java 就在栈中为这个变量分配内存空间, ...