证书创建三步曲:

一、密钥文件

二、请求文

三、根证书签名

最后看需要是否合并证书文件

1. 创立根证书密钥文件(自己做CA)root.key:

[kk@test ~]$ openssl genrsa -des3 -out root.key
Generating RSA private key, 512 bit long modulus
……………..++++++++++++
..++++++++++++
e is 65537 (0×10001)
Enter pass phrase for root.key: ← 输入一个新密码
Verifying – Enter pass phrase for root.key: ← 重新输入一遍密码

2. 创立根证书的申请文件root.csr:
[kk@test ~]$ 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 ‘.whflsc.com’, 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:
[kk@test ~]$ openssl x509 -req -days 3650 -sha1 -extensions v3_ca -signkey root.key -in root.csr -out root.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./emailAddress=admin@mycompany.com
Getting Private key
Enter pass phrase for root.key: ← 输入前面创立的密码

4. 创立服务器证书密钥server.key:
[kk@test ~]$ openssl genrsa -out server.key 2048
Generating RSA private key, 2048 bit long modulus
….+++
…………………………………………..+++
e is 65537 (0×10001)

5.创立服务器证书的申请文件server.csr:
[kk@test ~]$ openssl req -new -key server.key -out server.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) []:om ← 服务器主机名,若填写不准确,博览器会报告证书无效,但并不波及利用
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 []: ← 能够不输入

6. 创立自目前日期起管用期为期两年的服务器证书server.crt:
[kk@test ~]$ openssl x509 -req -days 730 -sha1 -extensions v3_req -CA root.crt -CAkey root.key -CAcreateserial -in server.csr -out server.crt
Signature ok
subject=/C=CN/ST=BeiJing/L=BeiJing/O=MyCompany Corp./CN=om/emailAddress=admin@mycompany.com
Getting CA Private Key
Enter pass phrase for root.key: ← 输入前面创立的密码

7. 将server.crt和书密钥文件server.key并合成证书安装包server.pfx:
[kk@test ~]$ openssl pkcs12 -export -in server.crt -inkey server.key -out server.pfx
Enter pass phrase for server.key: ← 输入上面创立的密码
Enter Export Password: ← 输入一个新的密码,用作客户端证书的防御密码,在客户端安装证书时必需输入此密码
Verifying – Enter Export Password: ← 确认密码

Openssl生成证书三板斧的更多相关文章

  1. CentOS6系统openssl生成证书和自签证书

    CentOS6系统openssl生成证书和自签证书的过程,记录一下,本文基于CentOS 6 64bit.$ yum install openssl openssl-devel 1,生成服务器端的私钥 ...

  2. 使用OpenSSL生成证书

    使用OpenSSL生成证书 下载安装openssl,进入/bin/下面,执行命令(把ssl目录下的openssl.cnf 拷贝到bin目录下)1.首先要生成服务器端的私钥(key文件):openssl ...

  3. 如何利用OpenSSL生成证书

    此文已由作者赵斌授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 一.前言 最近为了测试内容分发网络(Content Delivery Network,简称 CDN)添加的新功 ...

  4. [转帖] ./demoCA/newcerts: No such file or directory openssl 生成证书时问题的解决.

    接上面一篇blog 发现openssl 生成server.crt 时有问题. 找了一个网站处理了一下: http://blog.sina.com.cn/s/blog_49f8dc400100tznt. ...

  5. 使用 openssl 生成证书

    一.openssl 简介 目前最流行的 SSL 密码库工具官网:https://www.openssl.org/source/ 构成部分 密码算法库 密钥和证书封装管理功能 SSL通信API接口 用途 ...

  6. PHP通过OpenSSL生成证书、密钥并且加密解密数据,以及公钥,私钥和数字签名的理解

    一.公钥加密假设一下,我找了两个数字,一个是1,一个是2.我喜欢2这个数字,就保留起来,不告诉你们(私钥),然后我告诉大家,1是我的公钥. 我有一个文件,不能让别人看,我就用1加密了.别人找到了这个文 ...

  7. openssl 生成证书基本原理

    摘自:http://blog.csdn.net/oldmtn/article/details/52208747 1. 基本原理 公司一个项目要进行交易数据传输,因为这个项目银行那边也是刚刚开始启动,所 ...

  8. centos7 openssl 生成证书给自己使用

    Step1: centos7 系统自己生成证书 给自己签发不安全的域名证书 openssl genrsa - #生成ca根秘钥 是长度 openssl req - -key ca.key -out c ...

  9. [k8s]通过openssl生成证书

    证书认证原理: http://www.cnblogs.com/iiiiher/p/7873737.html [root@m1 ssl]# cat master_ssl.cnf [req] req_ex ...

随机推荐

  1. C++小结

    1.输入:cin>>变量名: 输出:cout<<变量名<<endl: 2.类 public 公有,此类及其他类中使用   private 私有,只能在本类中使用   ...

  2. Android安全相关文章[不定期更新…]

    http://drops.wooyun.org/papers/2893 Intent scheme URL attack http://drops.wooyun.org/tips/3812 Andro ...

  3. lanmp之二 (奇葩问题)

    ps:该篇是接 lanmp -- 动静分离 lanmp -- 奇葩问题 话说,在 搭建 bbs.abc.com (discuz论坛)的 时候.... 1.说明:web机器上以前已经有一个 discuz ...

  4. ember.js路由无效的解决思路

    进入今天的问题,就是route ember中就一个html,单页面程序(spa),所以页面的跳转,也可以叫做页面的路由,其实就是在这一个html中,不断的进行html的插入和删除了(个人理解) emb ...

  5. 初识MVC

    本人是一个程序员,我也是一个很普通很普通的人,当我初学一些东西的时候感觉都很难,毕竟没有天才的头脑,没有高等的学历,但是我有的只是努力,只是拼搏的精神,人都是为自己而活,也可能为他人而活,但是有时候在 ...

  6. Java笔记:Number

    序号 方法与描述 1 xxxValue()将number对象转换为xxx数据类型的值并返回. 2 compareTo()将number对象与参数比较. 3 equals()判断number对象是否与参 ...

  7. Riemann映射定理

    单复变函数几何理论最高的成就我想应该属于Riemann映射定理吧! Riemann映射定理:$\mathbb C$中任意边界多余一个点的单连通域$D$都与单位圆盘$B(0,1)$等价,即存在着$D$上 ...

  8. mysql5.6 忘记root密码

    1.首先net stop mysql服务,并且切换到任务管理器,有与mysql有关的,最好关闭进程. 2.运行CMD命令切换到MySql安装bin目录,下面是我的mysql安装目录 cd  D:\Pr ...

  9. Hadoop HA高可用性架构和演进分析(转)

    1.概况 截至目前,Apache Hadoop版本分为两代,我们将第一代Hadoop称为Hadoop 1.0,第二代Hadoop称为Hadoop 2.0.前者主要有如下几种实现方式:1)社区版本基于S ...

  10. ios 弹出不同的键盘

    iOS 提供了10种键盘类型,在开发中,我们可以根据不同的需求,选择不同的键盘样式,例如,当我们只需要输入手机号码时,可以选择纯数字类型的键盘(NumbersAndPunctuation),当我们需要 ...