openssl生成自签名证书

时间:2022-09-11 16:10:41

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生成自签名证书的更多相关文章

  1. 用OpenSSL生成自签名证书在IIS上搭建Https站点(用于iOS的https访问)

    前提: 先安装openssl,安装有两种方式,第一种直接下载安装包,装上就可运行:第二种可以自己下载源码,自己编译.这里推荐第一种. 安装包:http://slproweb.com/products/ ...

  2. OpenSSL使用1(用OpenSSL生成自签名证书在IIS上搭建Https站点)(用于iOS的https访问)

    前提: 先安装openssl,安装有两种方式,第一种直接下载安装包,装上就可运行:第二种可以自己下载源码,自己编译.这里推荐第一种. 安装包:http://slproweb.com/products/ ...

  3. 使用openssl创建自签名证书及部署到IIS教程

    概要 本文讲解三个部分:1. 创建自签名证书2. 创建自己的证书颁发机构3. 以及如何配置IIS 创建自签名证书 首先,创建一个私钥文件: openssl genrsa -out myselfsign ...

  4. openssl实现自签名证书

    前言 证书的作用 加密通信数据,验证对象身份,保证数据完整性 什么是自签名证书 公认的证书往往都需要收费,如果客户端与服务端都是由我们自己来操控,那便可以使用自签名证书(说白了就是只是自己认可的证书) ...

  5. cmd命令生成android签名证书

    cmd命令生成android签名证书,有空在写一篇eclipse导出带签名的apk,这里面包括生成新的签名.现在还是讲讲在cmd怎么操作生成签名证书. 1.dos下进入JDK的bin目录 运行如下命令 ...

  6. 使用terraform 生成自签名证书

    terraform 是一个很不错的基础设施工具,我们可以用来做关于基础设施部署的事情,可以实现基础设施即代码 以下演示一个简单的自签名证书的生成(使用tls provider) main.tf 文件 ...

  7. [ipsec][strongswan] 用strongswan pki工具生成自签名证书

    如题.我在实验环境里,分别要为两个endpoint(T9和T129)生成证书. 证书是如何生成的呢? 证书是由根证书机构签发的.申请证书的人将request提交给根证书机构,然后根证书机构根据requ ...

  8. 使用openssl生成双向加密证书(转)

    要生成证书的目录下建立几个文件和文件夹,有./demoCA/./demoCA/newcerts/./demoCA/private/./demoCA/index.txt (空文件,生成证书时会将数据记录 ...

  9. Windows下生成自签名证书

    最近通过openssl生成了自签名的证书,总结成下面这张图. 说明:下载openssl0.9.8之后解压,然后运行bin\openssl.exe进入openssl运行环境,然后按上图中顺序执行命令.( ...

随机推荐

  1. 关于mysql varchar 类型的最大长度限制

    Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This ...

  2. c++ 临时变量

    C++的临时变量 它们是被神所遗弃的孩子,没有人见过它们,更没有人知道它们的名字.它们命中注定徘徊于命运边缘高耸的悬崖和幽深的深渊之间,用自己短暂的生命抚平了生与死之间的缝隙.譬如朝露,却与阳光无缘. ...

  3. Linux基本命令(4)有关关机和查看系统信息的命令

    有关关机和查看系统信息的命令 命令 说明 shutdown 正常关机 reboot 重启计算机 ps 查看目前程序执行的情况 top 查看目前程序执行的情景和内存使用的情况 kill 终止一个进程 d ...

  4. 天池大数据周冠军分享|附移动推荐算法赛答辩会Top5选手PPT

    上周是淘宝穿衣搭配算法大赛开始评测后的第一周,周冠军是来自浙江大学的"FUC AUTH"队.他们在夺得本周冠军之后,还将自己的获胜经验分享给了大家,究竟有什么秘诀呢? 阿里巴巴天池 ...

  5. 坑爹的UICollectionView

    最近用UICoolectionView的时候遇到一个很DT的问题,我往VC里加12个视图,结果显示成这样(右边是期待的样子):       研究了一下午,终于发现了问题: @interface FpL ...

  6. php 解决大流量网站访问量问题

    当一个网站发展为知名网站的时候(如新浪,腾讯,网易,雅虎),网站的访问量通常都会非常大,如果使用虚拟主机的话,网站就会因为访问量过大而引起 服务器性能问题,这是很多人的烦恼,有人使用取消RSS等错误的 ...

  7. C期未考试参考答案

    输入10个数,要求编写一个排序函数,能够实现按绝对值从大到小排序.在主函数中输入10个数.输出排序后的10个数 #include<stdio.h>#include<math.h&gt ...

  8. mySQL语法中的存储过程及if语句的使用简例

    create procedure gh() #注意各个地方的分号!此代码应先运行除掉最后一句的部分,然后运行call gh显示已经存储的结果 BEGIN declare c_no int; #声明数据 ...

  9. C&plus;&plus; pair方法&sol;vector方法

    一,pair方法 类模板:template <class T1, class T2> struct pair 参数:T1是第一个值的数据类型,T2是第二个值的数据类型. 功能:pair将一 ...

  10. caffe网络结构可视化在线工具

    http://ethereon.github.io/netscope/#/editor shift+enter