证书创建三步曲:

一、密钥文件

二、请求文

三、根证书签名

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

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. SQLite.Net-PCLUSING SQLITE IN WINDOWS 10 UNIVERSAL APPS

    USING SQLITE IN WINDOWS 10 UNIVERSAL APPS 1.下载SQLite VSIX package并安装 http://sqlite.org/download.html ...

  2. LL(1)文法

    <源程序>→<外部声明>|<外部声明><函数体> <外部申明>→<头文件><函数声明>|其他声明 <函数体&g ...

  3. 用友U8 归纳采购退货结算三种情况

    对应版本: 8.52 问题现象: 客户经常处理退货结算的问题 问题原因: 应系统掌握各种情况 解决方案: 结算前全额退货即已录入采购入库单,但未进行采购结算,并且全额退货.填制一张全额数量的红字采购入 ...

  4. for_each(c++11)

    http://www.cplusplus.com/reference/algorithm/for_each/ template<class InputIterator, class Functi ...

  5. ElasticSearch性能优化官方建议

    ES 手册 如何提高ES的性能 不要返回较大的结果集 ES是设计成一个搜索引擎的,只擅长返回匹配查询较少文档,如果需要返回非常多的文档需要使用Scroll. 避免稀疏 因为ES是基于Lucene来索引 ...

  6. ExtJS基础知识总结:常用控件使用方式(一)

    概述 最近一直在做相关ExtJs方面的项目,遇到了ExtJs使用方面的一系列问题,现在将使用技巧做个记录汇总,以便于下次能够快速使用.以下都是ExtJs控件的常用方法,做简单汇总,俗话说,好记星不如烂 ...

  7. 【Java EE 学习 82 上】【MAVEN基本安装和使用方法】

    一.Maven概述 1.什么是Maven? Maven中文意思是"行家"."专家",它是一种跨平台的项目管理工具. 2.Maven有什么作用? Maven能够实 ...

  8. PE文件格式(加密与解密3)(一)

    本次的了解主要讲解 PE的基本概念.MS-DOS文件头.PE文件头.区块.输入表.输出表等. 这里我将会结合一个简单的小程序来加深我对PE文件结构的了解. 使用学习工具:有StudyPE.LordPE ...

  9. html5+css3+jquery完成响应式布局

    响应式布局,流体布局,自适应布局,静态布局等等,这是移动设备的飞速发展,前端人员不得不跟上潮流的一个方向.实际上各种设备尺寸,分辨率大都不同,真的适应各种设备依旧是不现实的,首先是浏览器差异化,让我们 ...

  10. three.js立方体

    <!DOCTYPE html> <html lang="en"> <head> <title>three.js webgl - ge ...