证书创建三步曲:

一、密钥文件

二、请求文

三、根证书签名

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

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. xtrabackup 使用说明(续)

    背景: 关于物理备份工具xtrabackup的一些说明可以先看之前写过的文章说明:xtrabackup 安装使用.现在xtrabackup版本升级到了2.4.4,相比之前的2.1有了比较大的变化:in ...

  2. POJ 2299 Ultra-QuickSort 线段树

    题目链接 题意:求冒泡排序的交换次数,即求逆序数,即求对于每个数前面有多少个数比他大,n < 500,000,0 ≤ a[i] ≤ 999,999,999. 题解:因为值较大,个数较少,所以我们 ...

  3. shell 输出九九乘法表

    #/bin/bash i= j= )) do while(($j<=$i)) do echo -ne $j×$i=$[$j*$i]"\t" j=$[$j+] done ech ...

  4. 文件上传之 HttpPostedFile

    HttpPostedFile类,提供对客户端已上载的单独文件的访问. 公共属性如下: SaveAs()方法,用于保存上传文件的内容. 用法为: #region 文件上传 /// <summary ...

  5. xss漏洞修复,待完善

    1.防止sql注入 /// <summary> /// 分析用户请求是否正常 /// </summary> /// <param name="Str" ...

  6. HTML中块级元素与行内元素

    一.行内元素与块级元素 块级元素列表 <address> 定义地址 <caption> 定义表格标题 <dd> 定义列表中定义条目 <div> 定义文档 ...

  7. tif文件导入postgresql

    raster2pgsql -I -F -N -999  文件名  数据库名 | psql -U postgres -d postgres

  8. Linux 使用Crontab设置定时调用Shell文件

    定时执行步骤: 利用crontab来定时执行任务大致有如下两步: 1.编写shell脚本 2.利用crontab加入到定时任务队列 一.如何建立shell脚本 程序必须以下面的行开始(必须方在文件的第 ...

  9. [Git] 还原Git上commit,但是没有push代码

    直接在Idea上操作2步解决: 1. 找到: 2. 在To Commit里面填写:HEAD^,表示将commit的信息还原为上一次的,需要多次直接reset多次即可: 使用命令行:原理一样 以下内容转 ...

  10. Netty参数配置表