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. AES对称加密算法

    package cn.jsonlu.passguard.utils; import org.apache.commons.codec.binary.Base64; import javax.crypt ...

  2. windows服务状态自动启动

    很多人制作成Windows服务安装包时发现明明在属性里面设置了自动启动,可在服务安装完成以后,还需要手动启动服务,我这里有一种完全实现自动启动的方法 在ProjectInstaller.cs 文件做文 ...

  3. UIViewController的View显示在导航栏下面如何解决?

    ios7之前的版本中UIViewController中的view在显示后会自动调整为去掉导航栏的高度的,控件会自动在导航栏以下摆放. 在iOS7中UIViewController的wantsFullS ...

  4. Python标准库--os模块

    这个模块包含普遍的操作系统功能.如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的.即它允许一个程序在编写后不需要任何改动,也不会发生任何问题,就可以在Linux和Windows下运行.一个例 ...

  5. centos 下搭建 php环境(1)

    3.PHP的安装 安装GD库(让PHP支持GIF,PNG,JPEG) 首先下载 jpeg6,libpng,freetype 并安装模块 wget http://www.ijg.org/files/jp ...

  6. 一个测ip和端口是否联通的工具类

    public class TestIp { public static void main(String[] args) { Socket connect = new Socket(); try { ...

  7. listview底部增加按钮

    View bottomView=getActivity().getLayoutInflater().inflate(R.layout.btn_my_course, null); myCourses = ...

  8. 常用的JQuery UI框架

    http://www.ligerui.com/ http://www.jeasyui.com/index.php http://www.jqwidgets.com/

  9. Mahout

    http://blog.csdn.net/yueyedeai/article/details/26567379

  10. 等待事件--db file sequential read

    对于最小化db file sequential read 事件所带来的影响,你可以做的另一件事情是减少AVERAGE_WAIT时间. 这是会话必须等待从磁盘提取单块的平均时间,这些信息可以从v$ses ...