使用openssl工具生成证书
第一步. 生成rsa私钥文件
:\> openssl genrsa -out bexio.pem 1024
: 若要加密生成的rsa私钥文件(des3加密)
:\> openssl genrsa -des3 -out bexio.pem 1024
第二步. 生成Certificate Signing Request(CSR - 证书请求文件)
:\> openssl req -new -key bexio.pem -out bexio.csr -config openssl.cnf
: 根据交互提示一步一步输入必要信息, 敲击回车可以跳过, 以下是一个简单的例子
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:china
Locality Name (eg, city) []:xiamen
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:289633152@qq.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
第三步. 把证书请求文件认证为可用证书
(1) 生产CA根证书(用于签名)
: 把openssl.cnf复制到openssl.exe所在目录
:\> openssl req -new -x509 -keyout ca.key -out ca.crt -config openssl.cnf
执行成功以后, 在oepnssl所在目录便生成了ca.key和ca.crt两个文件. 其中ca.key存的是CA根证书的私钥, ca.crt存的便是CA根证书.
(2) 准备CA环境
: 把openssl.cnf复制到openssl.exe所在目录, 修改其中的ca section, 添加新的ca策略. 如下:
####################################################################
[ ca ]
default_ca = CA_BEXIO #CA_default # The default ca section
####################################################################
[ CA_BEXIO ]
dir = .# Where everything is kept
certs = $dir# Where the issued certs are kept
crl_dir = $dir# Where the issued crl are kept
database = $dir/index.txt# database index file.
new_certs_dir = $dir# default place for new certs.
certificate = $dir/ca.crt# The CA certificate
serial = $dir/serial# The current serial number
crlnumber = $dir/crlnumber# the current crl number
# must be commented out to leave a V1 CRL
crl = $dir/crl.pem# The current CRL
private_key = $dir/ca.key# The private key
RANDFILE = $dir/.rand# private random number file
x509_extensions = usr_cert# The extentions to add to the cert
# Comment out the following two lines for the "traditional"
# (and highly broken) format.
name_opt = ca_default# Subject Name options
cert_opt = ca_default# Certificate field options
# Extension copying option: use with caution.
# copy_extensions = copy
# Extensions to add to a CRL. Note: Netscape communicator chokes on V2 CRLs
# so this is commented out by default to leave a V1 CRL.
# crlnumber must also be commented out to leave a V1 CRL.
# crl_extensions = crl_ext
default_days = 3650# how long to certify for
default_crl_days= 30# how long before next CRL
default_md = default# use public key default MD
preserve = no# keep passed DN ordering
# A few difference way of specifying how similar the request should look
# For type CA, the listed attributes must be the same, and the optional
# and supplied fields are just that :-)
policy = policy_anything
: 生成证书索引文件和数据库文件
\Linux:
$ touch index.txt
$ echo 01> serial
\Windows:
:\> copy con index.txt
:\> <Ctrl-z>
:\> echo 01> serial
: 修改openssl.cnf中的配置项如下:
[ policy_anything ]
countryName = optional
stateOrProvinceName = optional
localityName = optional
organizationName = optional
organizationalUnitName = optional
commonName = optional
emailAddress = optional
(3) CA签名
:\> openssl ca -in bexio.csr -out bexio.crt -config openssl.cnf
至此, 生成的证书相关文件有: ca.crt (ca根证书) bexio.pem(私钥) bexio.crt(证书)
在使用时, 私钥和证书可以合并为一个文件.
\Linux:
$ cat bexio.pem >> bexio.crt
\Windows:
用文本编辑器把内容拷贝过去即可
使用openssl工具生成证书的更多相关文章
- 如何使用OpenSSL工具生成根证书与应用证书
如何使用OpenSSL工具生成根证书与应用证书 一.步骤简记 // 生成顶级CA的公钥证书和私钥文件,有效期10年(RSA 1024bits,默认) openssl req -new -x509 -d ...
- tomcat配置https–采用JDK自带的keytool工具生成证书
转自:http://blog.csdn.net/huangxinyu_it/article/details/41693633 有关http与https的区别请看<浅谈http与https的区别( ...
- openssl req(生成证书请求和自建CA)(转)
openssl req(生成证书请求和自建CA) 伪命令req大致有3个功能:生成证书请求文件.验证证书请求文件和创建根CA.由于openssl req命令选项较多,所以先各举几个例子,再集中 ...
- openssl req(生成证书请求和自建CA)
伪命令req大致有3个功能:生成证书请求文件.验证证书请求文件和创建根CA.由于openssl req命令选项较多,所以先各举几个例子,再集中给出openssl req的选项说明.若已熟悉openss ...
- openssl基本原理 + 生成证书 + 使用实例
前期准备 : 安装xampp:打开文件E:\xampp\apache\bin\openssl.exe 右键 以管理员身份运行 ------转载自 https://blog.csdn.net/oldm ...
- 使用JDK自带的keytool工具生成证书
一.keytool 简介 keytool 是java用于管理密钥和证书的工具,它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认证自己)或数据完整性以及 ...
- 使用openssl工具生成密钥
下载Openssl工具 进入OpenSSL工具,输入以下命令. OpenSSL> genrsa - #生成私钥 OpenSSL> pkcs8 -topk8 -inform PEM -in ...
- Linux 部署Nginx反向代理服务 使用openssl自生成证书并配置https
1.安装Nginx编译所依赖的包 正常centos中可以使用yum安装一下依赖包: yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel ...
- 如何用java自带的工具生成证书
一.keytool的概念 keytool 是个密钥和证书管理工具.它使用户能够管理自己的公钥/私钥对及相关证书,用于(通过数字签名)自我认证(用户向别的用户/服务认证自己)或数据完整性以及认证服务.在 ...
随机推荐
- 离线树状数组 hihocoder 1391 Countries
官方题解: // 离线树状数组 hihocoder 1391 Countries #include <iostream> #include <cstdio> #include ...
- STL"源码"剖析-重点知识总结
STL是C++重要的组件之一,大学时看过<STL源码剖析>这本书,这几天复习了一下,总结出以下LZ认为比较重要的知识点,内容有点略多 :) 1.STL概述 STL提供六大组件,彼此可以组合 ...
- c/c++工程中外部头文件及库添加方法
在VS工程中,添加c/c++工程中外部头文件及库的基本步骤: 1.添加工程的头文件目录:工程---属性---配置属性---c/c++---常规---附加包含目录:加上头文件存放目录. 2.添加文件引用 ...
- socket 粘包问题(转)
https://www.v2ex.com/t/234785#reply3 1. 面向字节流的 IO 都有这个问题. socket 中 tcp 协议是面向流的协议,发送方发送和接收方的接收并不是一一对应 ...
- air 移动开发配置文件详解
转自http://www.badyoo.com/index.php/2012/09/12/208/index.html 目录 所需的 AIR 运行时版本 应用程序标识 应用程序版本 主应用程序 SWF ...
- OpenGL复习要点II
[OpenGL复习要点II] 1.视图变换必须出现在模型变换之前. 2.glMatrixMode()参数有三个,GL_MODELVIEW,GL_PROJECTION,GL_TEXTURE. 3.变换顺 ...
- C++11空指针
[C++11空指针] 早在 1972 年,C语言诞生的初期,常数 0 带有常数及空指针的双重身分. C 使用 preprocessor macro NULL 表示空指针, 让 NULL 及 0 分别代 ...
- 用完成例程(Completion Routine)实现的重叠I/O模型
/// 用完成例程(Completion Routine)实现的重叠I/O模型 /// 异步IO模型 /// 用完成例程来实现重叠I/O比用事件通知简单得多.在这个模型中,主线程只用不停的接受连接 / ...
- Jquery 操作 radio选中值
1.获取radio选中值 1.1 $('input:radio:checked').val(); 1.2 $("input[type='radio']:checked").va ...
- JedisPoolConfig配置
JedisPoolConfig config = new JedisPoolConfig(); //连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true config. ...