openssl生成自签名证书
1、生成x509格式的CA自签名证书
openssl req -new -x509 -keyout ca.key -out ca.crt
2、生成服务端的私钥(key文件)及申请证书文件csr文件
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr
3、生成客户端的私钥(key文件)及申请证书csr文件
openssl genrsa -des3 -out client.key 1024
openssl req -new -key client.key -out client.csr
4、用生成的CA的证书为刚才生成的server.csr,client.csr文件签名
openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key
openssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key
5、生成p12格式证书
openssl pkcs12 -export -inkey client.key -in client.crt -out client.pfx
openssl pkcs12 -export -inkey server.key -in server.crt -out server.pfx
6、生成pem格式证书
有时需要用到pem格式的证书,可以用以下方式合并证书文件(crt)和私钥文件(key)来生成。
cat client.crt client.key> client.pem
cat server.crt server.key > server.pem
7、pfx文件转换为X509证书文件和RSA密钥文件
openssl pkcs12 -in server.pfx -nodes -out server.pem
openssl x509 -in server.pem -out server2.crt
openssl rsa -in server.pem -out server2.key
注意:CA在签证时会出现如下错误,解决方法:
[root@station23 test]# openssl ca -in my.csr -out ldap.crt
Using configuration from /etc/pki/tls/openssl.cnf
I am unable to access the /etc/pki/CA/newcerts directory
/etc/pki/CA/newcerts: No such file or directory
[root@station23 test]# mkdir /etc/pki/CA/newcerts
[root@station23 test]# openssl ca -in my.csr -out ldap.crt
Using configuration from /etc/pki/tls/openssl.cnf
/etc/pki/CA/index.txt: No such file or directory
unable to open '/etc/pki/CA/index.txt'
23016:error:02001002:system library:fopen:No such file or directory:bss_file.c:352:fopen('/etc/pki/CA/index.txt','r')
23016:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:354:
[root@station23 test]# touch /etc/pki/CA/index.txt
[root@station23 test]# openssl ca -in my.csr -out ldap.crt
Using configuration from /etc/pki/tls/openssl.cnf
/etc/pki/CA/serial: No such file or directory
error while loading serial number
23031:error:02001002:system library:fopen:No such file or directory:bss_file.c:352:fopen('/etc/pki/CA/serial','r')
23031:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:354:
[root@station23 test]# touch /etc/pki/CA/serial
[root@station23 test]# echo 00 > /etc/pki/CA/serial
openssl生成自签名证书的更多相关文章
- 用OpenSSL生成自签名证书在IIS上搭建Https站点(用于iOS的https访问)
前提: 先安装openssl,安装有两种方式,第一种直接下载安装包,装上就可运行:第二种可以自己下载源码,自己编译.这里推荐第一种. 安装包:http://slproweb.com/products/ ...
- OpenSSL使用1(用OpenSSL生成自签名证书在IIS上搭建Https站点)(用于iOS的https访问)
前提: 先安装openssl,安装有两种方式,第一种直接下载安装包,装上就可运行:第二种可以自己下载源码,自己编译.这里推荐第一种. 安装包:http://slproweb.com/products/ ...
- 使用openssl创建自签名证书及部署到IIS教程
概要 本文讲解三个部分:1. 创建自签名证书2. 创建自己的证书颁发机构3. 以及如何配置IIS 创建自签名证书 首先,创建一个私钥文件: openssl genrsa -out myselfsign ...
- openssl实现自签名证书
前言 证书的作用 加密通信数据,验证对象身份,保证数据完整性 什么是自签名证书 公认的证书往往都需要收费,如果客户端与服务端都是由我们自己来操控,那便可以使用自签名证书(说白了就是只是自己认可的证书) ...
- cmd命令生成android签名证书
cmd命令生成android签名证书,有空在写一篇eclipse导出带签名的apk,这里面包括生成新的签名.现在还是讲讲在cmd怎么操作生成签名证书. 1.dos下进入JDK的bin目录 运行如下命令 ...
- 使用terraform 生成自签名证书
terraform 是一个很不错的基础设施工具,我们可以用来做关于基础设施部署的事情,可以实现基础设施即代码 以下演示一个简单的自签名证书的生成(使用tls provider) main.tf 文件 ...
- [ipsec][strongswan] 用strongswan pki工具生成自签名证书
如题.我在实验环境里,分别要为两个endpoint(T9和T129)生成证书. 证书是如何生成的呢? 证书是由根证书机构签发的.申请证书的人将request提交给根证书机构,然后根证书机构根据requ ...
- 使用openssl生成双向加密证书(转)
要生成证书的目录下建立几个文件和文件夹,有./demoCA/./demoCA/newcerts/./demoCA/private/./demoCA/index.txt (空文件,生成证书时会将数据记录 ...
- Windows下生成自签名证书
最近通过openssl生成了自签名的证书,总结成下面这张图. 说明:下载openssl0.9.8之后解压,然后运行bin\openssl.exe进入openssl运行环境,然后按上图中顺序执行命令.( ...
随机推荐
- Photon的log使用
添加log引用,设置log文件在Photon根目录下的log文件夹内. using ExitGames.Logging;using ExitGames.Logging.Log4Net; public ...
- 对ajax的hack的分析
先上原文链接:对jQuery ajax请求成功(失败)回调执行前的统一处理(兼容较老版本jQuery) 原文中已经提到了使用场景了,我觉得这非常适合单页面应用,还有backbone应用中.毕竟ajax ...
- 【转】 iOS使用AVFoundation实现二维码扫描
原文:http://strivingboy.github.io/blog/2014/11/08/scan-qrcode/ 关于二维码扫描有不少优秀第三方库如: ZBar SDK 里面有详细的文档,相应 ...
- Visual Studio 2010 单元测试目录
单元测试的重要性这里我就不多说了,以前大家一直使用NUnit来进行单元测试,其实早在Visual Studio 2005里面,微软就已经集成了一个叫Test的专门测试插件,经过几年的发展,这个工具现在 ...
- FindBugs的Bug类型及分析
FindBugs分析记录 Bad Practice: Class defines a clone() method but the class doesn't implement Cloneable. ...
- ueditor 1.4.3.2 独立/单独 上传图片框原理
其实简单的说就是编辑框很多按钮,所有按钮的功能都是以command形式提供,所以execCommand就是执行这些功能的命令.有些按钮是能弹出显示一个对话框,他的基类就是dialog,而所有被弹出的d ...
- exit() die return 的区别
rutrun 会返回一个值,或不返回值 只是当前函数内return后面的语句将不会执行,后面的其它语句继续执行exit()可以返回值,也可以不返回值直接终止程序 函数输出一条消息,并退出当前脚本. 会 ...
- HDU 5224 Tom and paper(最小周长)
HDU 5224 Tom and paper(最小周长) Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d &a ...
- SCJP_104——题目分析(4)
14. which three are valid declaraction of a float? ADFA. float foo=-1; B. float foo=1.0; C. float fo ...
- windows10 预览版 中英文官方下载地址+激活密钥+网盘分享
windows10 预览版 中英文官方下载地址+激活密钥+网盘分享 产品密钥:NKJFK-GPHP7-G8C3J-P6JXR-HQRJR 英语 64 位 (x64) http://iso.esd.m ...