1、yum install openssl安装openssl组件
2、生成KEY的流程步骤如下

1. 创建根证书密钥文件(自己做CA)root.key
 openssl genrsa -out root.key

输出内容为:

[lenin@archer ~]$ openssl genrsa -des3 -out root.key 
Generating RSA private key, 512 bit long modulus 
……………..++++++++++++ 
..++++++++++++ 
e is 65537 (0×10001)

2. 创建根证书的申请文件root.csr

openssl req -new -key root.key -out root.csr

输出内容为:

[lenin@archer ~]$ openssl req -new -key root.key -out root.csr 
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 ← 国家代号,中国输入CN 
State or Province Name (full name) [Some-State]:BeiJing ← 省的全名,拼音 
Locality Name (eg, city) []:BeiJing ← 市的全名,拼音 
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名 
Organizational Unit Name (eg, section) []: ← 可以不输入 
Common Name (eg, YOUR name) []: ← 此时不输入 
Email Address []:admin@mycompany.com ← 电子邮箱,可随意填

Please enter the following ‘extra’ attributes 
to be sent with your certificate request 
A challenge password []: ← 可以不输入

An optional company name []: ← 可以不输入

3. 创建一个自当前日期起为期十年的根证书root.crt

openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crt

输出内容为:
[lenin@archer ~]$ openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crt

Getting Private key 
subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./emailAddress=admin@mycompany.com 
Signature ok

4. 创建服务器证书密钥server.key

openssl genrsa -out server.key 2048

输出内容为:

[lenin@archer ~]$ openssl genrsa -out server.key 2048 
Generating RSA private key, 2048 bit long modulus 
….+++ 
…………………………………………..+++ 
e is 65537 (0×10001)

去除key文件口令的命令: openssl rsa -in server.key -out server.key
运行时会提示输入密码,此密码用于加密key文件(参数des3便是指加密算法,当然也可以选用其他你认为安全的算法.),以后每当需读取此文件(通过openssl提供的命令或API)都需输入口令.如果觉得不方便,也可以去除这个口令,但一定要采取其他的保护措施!

5.创建服务器证书的申请文件server.csr

openssl req -new -key server.key -out server.csr

输出内容为:

[lenin@archer ~]$ openssl req -new -key server.key -out server.req 
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 ← 国家名称,中国输入CN 
State or Province Name (full name) [Some-State]:BeiJing ← 省名,拼音 
Locality Name (eg, city) []:BeiJing ← 市名,拼音 
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名 
Organizational Unit Name (eg, section) []: ← 可以不输入 
Common Name (eg, YOUR name) []:www.mycompany.com ← 服务器主机名,若填写不正确,浏览器会报告证书无效,但并不影响使用 
Email Address []:admin@mycompany.com ← 电子邮箱,可随便填

An optional company name []: ← 可以不输入
A challenge password []: ← 可以不输入 
to be sent with your certificate request 
Please enter the following ‘extra’ attributes

6. 创建自当前日期起有效期为期十年的服务器证书server.crt

openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in server.csr -out server.crt

输出内容为:
[lenin@archer ~]$ openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in server.csr -out server.crt

Getting CA Private Key

subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=www.mycompany.com/emailAddress=admin@mycompany.com 
Signature ok

7. 创建客户端证书密钥文件client.key

openssl genrsa -out client.key 2048

输出内容为:

[lenin@archer ~]$ openssl genrsa -out client.key 2048

e is 65537 (0×10001) 
……………………………………………………………………………………………………….+++ 
……………………………………………………………………………..+++ 
Generating RSA private key, 2048 bit long modulus

8. 创建客户端证书的申请文件client.csr

openssl req -new -key client.key -out client.csr

输出内容为:

[lenin@archer ~]$ openssl req -new -key client.key -out client.csr 
Enter pass phrase for 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) [AU]:CN ← 国家名称,中国输入CN 
State or Province Name (full name) [Some-State]:BeiJing ← 省名称,拼音 
Locality Name (eg, city) []:BeiJing ← 市名称,拼音 
Organization Name (eg, company) [Internet Widgits Pty Ltd]:MyCompany Corp. ← 公司英文名 
Organizational Unit Name (eg, section) []: ← 可以不填 
Common Name (eg, YOUR name) []:Lenin ← 自己的英文名,可以随便填 
Email Address []:admin@mycompany.com ← 电子邮箱,可以随便填

An optional company name []: ← 可以不填
A challenge password []: ← 可以不填 
to be sent with your certificate request

Please enter the following ‘extra’ attributes

9. 创建一个自当前日期起有效期为十年的客户端证书client.crt

openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAserial root.srl -CAcreateserial -in client.csr -out client.crt

输出内容为:

[lenin@archer ~]$ openssl x509 -req -days 3650 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial -in client.csr -out client.crt 
Signature ok 
subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=www.mycompany.com/emailAddress=admin@mycompany.com 
Getting CA Private Key

10. 将客户端证书文件client.crt和客户端证书密钥文件client.key合并成客户端证书安装包client.pfx

openssl pkcs12 -export -in client.crt -inkey client.key -out client.pfx

输出内容为:

[lenin@archer ~]$ openssl pkcs12 -export -in client.crt -inkey client.key -out client.pfx 
Enter Export Password: ← 输入一个新的密码,用作客户端证书的保护密码,在客户端安装证书时需要输入此密码 
Verifying – Enter Export Password: ← 确认密码,可以为空密码

11. 保存生成的文件备用,其中server.crtserver.key是配置单向SSL时需要使用的证书文件,client.crt是配置双向SSL时需要使用的证书文件,client.pfx是配置双向SSL时需要客户端安装的证书文件

.crt文件和.key可以合到一个文件里面,把2个文件合成了一个.pem文件(直接拷贝过去就行了)

Centos生成SSL证书的步骤的更多相关文章

  1. 如何在 CentOS 7 上生成 SSL 证书为 Nginx 加密

    本文首发:开发指南:如何在 CentOS 7 上安装 Nginx Let’s Encrypt 是由 Internet Security Research Group (ISRG) 开发的一个自由.自动 ...

  2. JDK自带工具keytool生成ssl证书

    前言: 因为公司项目客户要求使用HTTPS的方式来保证数据的安全,所以木有办法研究了下怎么生成ssl证书来使用https以保证数据安全. 百度了不少资料,看到JAVA的JDK自带生成SSL证书的工具: ...

  3. 使用openssl生成SSL证书完全参考手册

    一般来说,配置HTTPS/SSL的步骤为: 1.生成足够强度的私钥.需要考虑:算法,广泛采用的一般是RSA.键长度,RSA默认为512,一般应选择2048.密码,虽然私钥不一定要加密存储,但是加密存储 ...

  4. openssl生成ssl证书

    openssl生成ssl证书 x509证书一般会用到三类文,key,csr,crt. Key 是私用密钥openssl格,通常是rsa算法. Csr 是证书请求文件,用于申请证书.在制作csr文件的时 ...

  5. 生成ssl证书文件

    网上关于生成SSL证书文件的方法有很多,但我查了几个,发现有或多或少的错误,如下我图文并茂的展示,亲测无任何问题,分享给大家,谢谢. 1.创建根证书密钥文件(自己做CA)root.key openss ...

  6. 用 letsencrypt 生成 SSL 证书

    letsencrypt 生成 SSL 证书 事先配置好访问域名解析 在nginx 对应虚拟主机添加一个验证区域: 配置 nginx server { listen 80; ... location ~ ...

  7. 使用keytool生成ssl证书

    使用keytool生成ssl证书 在项目中由于要使用https访问项目,然后了解到jdk有一个自带的工具keytool可以用来生成ssl证书,从而可以通过https进行访问. 使用keytool生成s ...

  8. 用XCA(X Certificate and key management)可视化程序管理SSL 证书(2)--生成SSL证书请求

    在上个章节中,我们提到了怎样安装XCA(X Certificate and key management)程序.这个章节我们開始正式介绍怎样用XCA生成证书请求.假设大家用过java的话.肯定知道jd ...

  9. openssl生成SSL证书的流程

    SSL证书通过在客户端浏览器和Web服务器之间建立一条SSL安全通道(Secure socketlayer(SSL),SSL安全协议主要用来提供对用户和服务器的认证:对传送的数据进行加密和隐藏:确保数 ...

随机推荐

  1. hdu 2204 Eddy's爱好 容斥原理

    Eddy's爱好 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem ...

  2. Mac系统下adb工具的配置

    sudo vim ~/.bash_profile 增加如下内容 ANDROID_HOME=/Users/apple/Library/Android/sdk export PATH=$PATH:$AND ...

  3. redis高可用 - Master&Slave

    Master&Slave也就是我们所说的主从复制,即主机数据更新后根据配置和策略,自动同步到备机的机制.其中Master以写为主,Slave以读为主. Master&Slave的作用主 ...

  4. Codeforces 909C Python Indentation:树状数组优化dp

    题目链接:http://codeforces.com/contest/909/problem/C 题意: Python是没有大括号来标明语句块的,而是用严格的缩进来体现. 现在有一种简化版的Pytho ...

  5. D3.js学习笔记(六)——SVG基础图形和D3.js

    目标 在这一章,我们将会重温SVG图形,学习如何使用D3.js来创建这些图形. 这里会包括前面例子中的SVG基础图形以及如何使用D3.js设置图形的属性. 使用D3.js画一个SVG 的 圆 circ ...

  6. hive grouping sets 等聚合函数

    函数说明: grouping sets 在一个 group by 查询中,根据不同的维度组合进行聚合,等价于将不同维度的 group by 结果集进行 union allcube 根据 group b ...

  7. java中进行四舍五入

    在oracle中有一个很好的函数进行四舍五入,round(), select round(111112.23248987,6) from dual; 但是java的Number本身不提供四舍五入的方法 ...

  8. Big Table中文翻译

    题记:google 的成功除了一个个出色的创意外,还因为有 Jeff Dean 这样的软件架构天才. 官方的 Google Reader blog 中有对BigTable 的解释.这是Google 内 ...

  9. C#读写三菱Fx PLC 使用Fx 串口协议 读写Fx3U设备

    本文将使用一个Github开源的组件库技术来读写三菱 FX PLC,使用的是基于串口的实现,不需要额外的组件,读取操作只要放到后台线程就不会卡死线程,本组件支持超级方便的高性能读写操作 github地 ...

  10. 解决Eclipse中新创建的Maven项目不自动创建web.xml文件

    1. 通过J2EE tools 2.项目右键-properties-project facets-勾选dynamic web moudle