linux下利用openssl来实现证书的颁发(详细步骤)

合集下载

Linux系统利用OpenSSL生成SSL证书

Linux系统利用OpenSSL生成SSL证书

Linux上使用OpenSSL生成SSL证书Linux上使用OpenSSL生成SSL证书1 安装OpenSSL2 生成私钥文件(KEY)3 生成证书请求文件(CSR)4 生成自签名证书(CRT)5 配置服务器1 安装OpenSSL在终端输入以下命令来检查是否已安装OpenSSL:openssl version如果已安装,则可以看到OpenSSL的版本号。

如果未安装,需要根据所使用的Linux发行版进行安装,例如:Debian/Ubuntu:sudo apt-get install opensslCentOS/RHEL:sudo yum install openssl2 生成私钥文件(KEY)1. 执行以下命令生成一个私钥文件(例如private.key):openssl genrsa -out private.key 2048以上示例将生成一个2048位的RSA私钥。

3 生成证书请求文件(CSR)1. 执行以下命令生成一个证书请求文件(例如server.csr):openssl req -new-key private.key -out server.csr2. 在生成CSR的过程中,需要提供一些证书信息,例如:常用名称、国家、email、组织名称等,详细信息如下:You are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [XX]:cnState or Province Name (full name) []:bjLocality Name (eg, city) [Default City]:bjOrganization Name (eg, company) [Default Company Ltd]:bjOrganizational Unit Name (eg, section) []:bj4 生成自签名证书(CRT )1.以上示例将生成一个有效期为365天的自签名证书,将使用私钥文件来签名证书请求文件,可以根据需要调整证书的有效期5 配置服务器将生成的私钥文件和证书文件配置到Nginx 或Apache 等服务器上即可使用。

Linux下利用openssl 生成SSL证书步骤

Linux下利用openssl 生成SSL证书步骤

Linux下利用openssl 生成SSL证书步骤1、概念首先要有一个CA根证书,然后用CA根证书来签发用户证书。

用户进行证书申请:一般先生成一个私钥,然后用私钥生成证书请求(证书请求里应含有公钥信息),再利用证书服务器的CA根证书来签发证书。

2、后缀详解.key格式:私有的密钥.csr格式:证书签名请求(证书请求文件),含有公钥信息,certificate signing request 的缩写.crt格式:证书文件,certificate的缩写.crl格式:证书吊销列表,Certificate Revocation List的缩写.pem格式:用于导出,导入证书时候的证书的格式,有证书开头,结尾的格式3、添加 index.txt 和 serial 文件cd /etc/pki/CA/touch /etc/pki/CA/index.txttouch /etc/pki/CA/serialecho 01 > /etc/pki/CA/serial4、CA根证书的生成4.1 生成CA私钥(.key)openssl genrsa -out ca.key 2048[root@CA]# openssl genrsa -out ca.key 2048Generating RSA private key, 2048 bit long modulus.............+++.....+++e is 65537 (0x10001)4.2 生成CA证书请求(.csr)openssl req -new -key ca.key -out ca.csr[root@CA]# openssl req -new -key ca.key -out ca.csrYou are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [XX]:USState or Province Name (full name) []:ORLocality Name (eg, city) [Default City]:OROrganization Name (eg, company) [Default Company Ltd]:LXOROrganizational Unit Name (eg, section) []:LXORAQCommon Name (eg, your name or your server's hostname) []:Email Address []:eg@Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:demon2234An optional company name []:OR4.3 自签名得到根证书(.crt)(CA给自已颁发的证书)openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt[root@CA]# openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt Signature oksubject=/C=US/ST=OR/L=OR/O=LXOR/OU=LXORAQ/CN=/emailAddress=eg@ Getting Private key5、用户证书的生成5.1 生成私钥(.key)openssl genrsa -des3 -out server.key 1024[root@CA]# openssl genrsa -des3 -out server.key 1024Generating RSA private key, 1024 bit long modulus........++++++...................++++++e is 65537 (0x10001)Enter pass phrase for server.key:Verifying - Enter pass phrase for server.key:5.2 生成证书请求(.csr)openssl req -new -key server.key -out server.csr[root@CA]# openssl req -new -key server.key -out server.csrEnter pass phrase for server.key:You are about to be asked to enter information that will be incorporatedinto 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 blankFor some fields there will be a default value,If you enter '.', the field will be left blank.-----Country Name (2 letter code) [XX]:USState or Province Name (full name) []:ORLocality Name (eg, city) [Default City]:OROrganization Name (eg, company) [Default Company Ltd]:LXOROrganizational Unit Name (eg, section) []:LXORAQCommon Name (eg, your name or your server's hostname) []:Email Address []:eg@Please enter the following 'extra' attributesto be sent with your certificate requestA challenge password []:demon2234An optional company name []:OR5.3 用CA根证书签名得到证书(.crt)o penssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key[root@CA]# openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key Using configuration from /etc/pki/tls/fCheck that the request matches the signatureSignature okCertificate Details:Serial Number: 3 (0x3)ValidityNot Before: Mar 13 07:01:44 2018 GMTNot After : Mar 13 07:01:44 2019 GMTSubject:countryName = USstateOrProvinceName = ORorganizationName = LXORorganizationalUnitName = LXORAQcommonName = emailAddress = eg@X509v3 extensions:X509v3 Basic Constraints:CA:FALSENetscape Comment:OpenSSL Generated CertificateX509v3 Subject Key Identifier:11:62:12:26:6C:1C:56:CD:9D:B2:6A:65:06:24:57:27:3E:5C:BC:EAX509v3 Authority Key Identifier:DirName:/C=US/ST=OR/L=OR/O=LXOR/OU=LXORAQ/CN=/emailAddress=eg@ serial:C9:6E:10:F7:A5:40:8F:1DCertificate is to be certified until Mar 13 07:01:44 2019 GMT (365 days)Sign the certificate? [y/n]:yfailed to update database//错误提示,解决方法将/etc/pki/CA目录下的index.txt文件删除,重TXT_DB error number 2新创建一个index.txt文件。

openssl操作手册

openssl操作手册

OpenSSL 是一个开源的加密库,提供了各种加密算法、数字证书、SSL/TLS 协议等功能,被广泛用于网络安全和加密通信领域。

以下是OpenSSL 的一些常见用法和操作:1. 生成证书:使用OpenSSL 可以生成各种类型的数字证书,包括自签名证书、CA 证书、服务器证书、客户端证书等。

您可以使用OpenSSL 提供的命令行工具或API 接口来生成证书。

2. 加密和解密:OpenSSL 提供了各种加密算法,包括对称加密和非对称加密。

您可以使用OpenSSL 提供的命令行工具或API 接口来进行加密和解密操作。

3. 签名和验证:OpenSSL 提供了数字签名和验证的功能,可以用于保证数据的完整性和真实性。

您可以使用OpenSSL 提供的命令行工具或API 接口来进行签名和验证操作。

4. SSL/TLS 安全通信:OpenSSL 提供了SSL/TLS 协议的实现,可以用于安全通信。

您可以使用OpenSSL 提供的命令行工具或API 接口来实现SSL/TLS 安全通信。

5. 网络安全工具:OpenSSL 提供了各种网络安全工具,包括OpenSSL s_server、OpenSSL s_client、OpenSSL speed、OpenSSL rand 等。

这些工具可以用于测试和评估网络安全性能。

要使用OpenSSL,您需要安装OpenSSL 库,并包含相应的头文件。

在编写代码时,您可以调用OpenSSL 提供的函数和数据结构来实现您需要的加密、签名、SSL/TLS 安全通信等功能。

OpenSSL 提供了详细的文档和使用手册,您可以在OpenSSL 官方网站上找到完整的文档和参考手册。

在文档中,您可以找到各种函数的使用说明、示例代码和详细的接口说明,以帮助您更好地使用OpenSSL 库。

用OpenSSL命令行生成证书文件

用OpenSSL命令行生成证书文件

用OpenSSL命令行生成证书文件证书文件生成也许很多人和本人一样深有体会,使用OpenSSL库写一个加密通讯过程,代码很容易就写出来了,可是整个工作却花了了好几天。

除将程序编译成功外(没有可以使用的证书文件,编译成功了,它并不能跑起来,并不表示它能正常使用,所以......),还需生成必要的证书和私钥文件使双方能够成功验证对方。

找了n多的资料,很多是说的很模糊,看了n多的英文资料,还是没有办法(不知道是不是外国朋友都比较厉害,不用说明得太清?),无意间找到yawl(yawl@)写的文章,难得的汉字(呵呵)。

里面有生成证书部分,说到生成了Certificate Signing Request (CSR)文件后,就有点不太清楚了。

后面生成自签字证书在很多地方都可以找到的,签名这部分,yawl说mod_ssl有比较好的脚本,但是笔者一时找不到,就自己用openssl的ca命令来完成了,也不是很麻烦。

说说本人的操作环境:无盘工作站(有权限问题使用起来不太方便),操作目录是openssl/bin(没办法改不了环境变量,如果你可以改的话,就不用在这个目录下工作了),为了方便本人把apps下的f 也复制到了这个目录下来。

文件名都是以本人使用的来说了:1.首先要生成服务器端的私钥(key文件):openssl genrsa -des3 -out server.key 1024运行时会提示输入密码,此密码用于加密key文件(参数des3便是指加密算法,当然也可以选用其他你认为安全的算法.),以后每当需读取此文件(通过openssl提供的命令或API)都需输入口令.如果觉得不方便,也可以去除这个口令,但一定要采取其他的保护措施!去除key文件口令的命令:openssl rsa -in server.key -out server.key2.生成Certificate Signing Request(CSR)openssl req -new -key server.key -out server.csr -config f生成Certificate Signing Request(CSR),生成的csr文件交给CA签名后形成服务端自己的证书.屏幕上将有提示,依照其指示一步一步输入要求的个人信息即可.3.对客户端也作同样的命令生成key及csr文件:openssl genrsa -des3 -out client.key 1024openssl req -new -key client.key -out client.csr -config f4.CSR文件必须有CA的签名才可形成证书.可将此文件发送到verisign等地方由它验证,要交一大笔钱,何不自己做CA呢.openssl req -new -x509 -keyout ca.key -out ca.crt -config f5.用生成的CA的证书为刚才生成的server.csr,client.csr文件签名:Openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config fOpenssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key -config f现在我们所需的全部文件便生成了.另:client使用的文件有:ca.crt,client.crt,client.keyserver使用的文件有:ca.crt,server.crt,server.key.crt文件和.key可以合到一个文件里面,本人把2个文件合成了一个.pem文件(直接拷贝过去就行了)。

openssl用法

openssl用法

openssl用法OpenSSL是一款广泛使用的加密库,它提供了许多加密和安全功能的实现。

本篇文章将介绍OpenSSL的基本用法,包括生成和管理证书、加解密数据、生成密码散列等常见功能。

1. 生成公私钥对OpenSSL可以用来生成公私钥对,用于加密数据。

生成公私钥对的命令如下:openssl genpkey -algorithm RSA -out private.keyopenssl rsa -in private.key -pubout -out public.key 其中,-algorithm指定算法,-out指定输出的文件名,-in指定输入的文件名。

2. 生成证书OpenSSL可以生成自签名证书,命令如下:openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem其中,-newkey指定生成新的私钥,-nodes表示不加密私钥,-keyout指定私钥输出文件名,-x509指定生成自签名证书,-days指定证书有效期,-out指定证书输出文件名。

3. 加解密数据OpenSSL可以使用公私钥对加解密数据,命令如下:openssl rsautl -encrypt -in plaintext.txt -out ciphertext.txt -inkey public.keyopenssl rsautl -decrypt -in ciphertext.txt -out plaintext.txt -inkey private.key其中,-encrypt表示加密,-decrypt表示解密,-in指定输入文件名,-out指定输出文件名,-inkey指定输入的私钥或公钥。

4. 生成密码散列OpenSSL可以生成各种密码散列,包括MD5、SHA-1、SHA-256等,命令如下:openssl dgst -md5 -out message.md5 message.txtopenssl dgst -sha1 -out message.sha1 message.txtopenssl dgst -sha256 -out message.sha256 message.txt 其中,-md5表示使用MD5算法,-sha1表示使用SHA-1算法,-sha256表示使用SHA-256算法,-out指定输出文件名,message.txt 为输入文件名。

详解Linux(centos7)下安装OpenSSL安装图文方法

详解Linux(centos7)下安装OpenSSL安装图文方法

详解Linux(centos7)下安装OpenSSL安装图⽂⽅法OpenSSL是⼀个开源的ssl技术,由于我需要使⽤php相关功能,需要获取https的⽂件所以必须安装这个东西了,下⾯我整理了两种关于OpenSSL安装配置⽅法。

安装环境:操作系统:CentOs7安静OpenSSL Version:openssl-1.0.2j.tar.gz1、将下载的压缩包放在根⽬录,2、在⽂件夹下解压缩,命令:tar -xzf openssl-1.0.2j.tar.gz,得到openssl-1.0.2j⽂件夹3、进⼊解压的⽬录:cd openssl-1.0.2j4、设定Openssl 安装,( --prefix )参数为欲安装之⽬录,也就是安装后的档案会出现在该⽬录下:执⾏命令: ./config --prefix=/usr/local/openssl5、执⾏命令./config -t6.执⾏make,编译Openssl这⾥如果出现如下错误make[1]: gcc: Command not found⽣⽓上⽹查才发现我安装的CentOS7中没有GCC编译器保证系统⽹络畅通以后,执⾏命令 yum -y install gcc 安装GCC(注意,⼀定要忘了顺畅,不然安装不了)7、安装 Openssl:make install8、执⾏以下命令[root@localhost /]# cd /usr/local[root@localhost local]# ldd /usr/local/openssl/bin/openssl会出现类似如下信息:9、查看路径...]# which openssl查看版本...]# openssl version卸载旧版本 OpenSSL的⽅法apt-get purge opensslrm -rf /etc/ssl #删除配置⽂件以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

openssl使用流程

openssl使用流程

openssl使用流程OpenSSL使用流程介绍OpenSSL 是一个开源的加密工具包和安全通信协议实现库,提供了一系列的加密算法、SSL/TLS 防护和各种安全工具,广泛应用于网络通信、服务器配置、数字证书管理等各个领域。

本文将以OpenSSL 的使用流程为主题,一步一步详细回答。

一、准备工作1. 下载和安装OpenSSL:首先,我们需要从OpenSSL 的官方网站或其他可信来源下载并安装OpenSSL。

根据操作系统的不同,选择相应的版本进行下载和安装。

2. 生成RSA 密钥对:在开始使用OpenSSL 之前,建议先生成一对RSA 密钥对,用于后续的加密和解密操作。

在命令行中输入以下命令可以生成一个2048 位的RSA 密钥对:openssl genrsa -out private.key 2048该命令将生成一个名为private.key 的私钥文件,其中包含了生成的RSA 私钥。

接着,可以使用以下命令生成对应的公钥文件:openssl rsa -in private.key -pubout -out public.key这将生成一个名为public.key 的公钥文件,其中包含了与私钥对应的RSA 公钥。

二、公钥加密和私钥解密1. 加密数据:使用公钥加密数据是一种常见的操作,可以保证数据在传输过程中的机密性。

在命令行中输入以下命令可以使用公钥对数据进行加密:openssl rsautl -encrypt -pubin -inkey public.key -in plaintext.txt -out ciphertext.enc该命令将使用public.key 中的公钥对plaintext.txt 中的明文数据进行加密,并将密文数据存储到ciphertext.enc 文件中。

2. 解密数据:解密数据需要使用对应的私钥进行操作。

在命令行中输入以下命令可以使用私钥对密文数据进行解密:openssl rsautl -decrypt -inkey private.key -in ciphertext.enc -out plaintext.txt该命令将使用private.key 中的私钥对ciphertext.enc 中的密文数据进行解密,并将解密后的明文数据存储到plaintext.txt 文件中。

使用openssl生成证书

使用openssl生成证书

使⽤openssl⽣成证书⼀、openssl 简介openssl 是⽬前最流⾏的 SSL 密码库⼯具,其提供了⼀个通⽤、健壮、功能完备的⼯具套件,⽤以⽀持SSL/TLS 协议的实现。

官⽹:构成部分1. 密码算法库2. 密钥和证书封装管理功能3. SSL通信API接⼝⽤途1. 建⽴ RSA、DH、DSA key 参数2. 建⽴ X.509 证书、证书签名请求(CSR)和CRLs(证书回收列表)3. 计算消息摘要4. 使⽤各种 Cipher加密/解密5. SSL/TLS 客户端以及服务器的测试6. 处理S/MIME 或者加密邮件⼆、RSA密钥操作默认情况下,openssl 输出格式为 PKCS#1-PEM⽣成RSA私钥(⽆加密)openssl genrsa -out rsa_private.key 2048⽣成RSA公钥openssl rsa -in rsa_private.key -pubout -out rsa_public.key⽣成RSA私钥(使⽤aes256加密)openssl genrsa -aes256 -passout pass:111111 -out rsa_aes_private.key 2048其中 passout 代替shell 进⾏密码输⼊,否则会提⽰输⼊密码;⽣成加密后的内容如:-----BEGIN RSA PRIVATE KEY-----Proc-Type: 4,ENCRYPTEDDEK-Info: AES-256-CBC,5584D000DDDD53DD5B12AE935F05A007Base64 Encoded Data-----END RSA PRIVATE KEY-----此时若⽣成公钥,需要提供密码openssl rsa -in rsa_aes_private.key -passin pass:111111 -pubout -out rsa_public.key其中 passout 代替shell 进⾏密码输⼊,否则会提⽰输⼊密码;转换命令私钥转⾮加密openssl rsa -in rsa_aes_private.key -passin pass:111111 -out rsa_private.key私钥转加密openssl rsa -in rsa_private.key -aes256 -passout pass:111111 -out rsa_aes_private.key私钥PEM转DERopenssl rsa -in rsa_private.key -outform der-out rsa_aes_private.der-inform和-outform 参数制定输⼊输出格式,由der转pem格式同理查看私钥明细openssl rsa -in rsa_private.key -noout -text使⽤-pubin参数可查看公钥明细私钥PKCS#1转PKCS#8openssl pkcs8 -topk8 -in rsa_private.key -passout pass:111111 -out pkcs8_private.key其中-passout指定了密码,输出的pkcs8格式密钥为加密形式,pkcs8默认采⽤des3 加密算法,内容如下:-----BEGIN ENCRYPTED PRIVATE KEY-----Base64 Encoded Data-----END ENCRYPTED PRIVATE KEY-----使⽤-nocrypt参数可以输出⽆加密的pkcs8密钥,如下:-----BEGIN PRIVATE KEY-----Base64 Encoded Data-----END PRIVATE KEY-----三、⽣成⾃签名证书⽣成 RSA 私钥和⾃签名证书openssl req -newkey rsa:2048 -nodes -keyout rsa_private.key -x509 -days 365 -out cert.crtreq是证书请求的⼦命令,-newkey rsa:2048 -keyout private_key.pem 表⽰⽣成私钥(PKCS8格式),-nodes 表⽰私钥不加密,若不带参数将提⽰输⼊密码;-x509表⽰输出证书,-days365 为有效期,此后根据提⽰输⼊证书拥有者信息;若执⾏⾃动输⼊,可使⽤-subj选项:openssl req -newkey rsa:2048 -nodes -keyout rsa_private.key -x509 -days 365 -out cert.crt -subj "/C=CN/ST=GD/L=SZ/O=vihoo/OU=dev/CN=/emailAddress=yy@"使⽤已有RSA 私钥⽣成⾃签名证书openssl req -new -x509 -days 365 -key rsa_private.key -out cert.crt-new 指⽣成证书请求,加上-x509 表⽰直接输出证书,-key 指定私钥⽂件,其余选项与上述命令相同四、⽣成签名请求及CA 签名使⽤ RSA私钥⽣成 CSR 签名请求openssl genrsa -aes256 -passout pass:111111 -out server.key 2048openssl req -new -key server.key -out server.csr此后输⼊密码、server证书信息完成,也可以命令⾏指定各类参数openssl req -new -key server.key -passin pass:111111 -out server.csr -subj "/C=CN/ST=GD/L=SZ/O=vihoo/OU=dev/CN=/emailAddress=yy@"*** 此时⽣成的 csr签名请求⽂件可提交⾄ CA进⾏签发 ***查看CSR 的细节cat server.csr-----BEGIN CERTIFICATE REQUEST-----Base64EncodedData-----END CERTIFICATE REQUEST-----openssl req -noout -text -in server.csr使⽤ CA 证书及CA密钥对请求签发证书进⾏签发,⽣成 x509证书openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -passin pass:111111 -CAcreateserial -out server.crt其中 CAxxx 选项⽤于指定CA 参数输⼊五、证书查看及转换查看证书细节openssl x509 -in cert.crt -noout -text转换证书编码格式openssl x509 -in cert.cer -inform DER -outform PEM -out cert.pem合成 pkcs#12 证书(含私钥)** 将 pem 证书和私钥转 pkcs#12 证书 **openssl pkcs12 -export -in server.crt -inkey server.key -passin pass:111111 -password pass:111111 -out server.p12其中-export指导出pkcs#12 证书,-inkey 指定了私钥⽂件,-passin 为私钥(⽂件)密码(nodes为⽆加密),-password 指定 p12⽂件的密码(导⼊导出)** 将 pem 证书和私钥/CA 证书合成pkcs#12 证书**openssl pkcs12 -export -in server.crt -inkey server.key -passin pass:111111 \-chain -CAfile ca.crt -password pass:111111 -out server-all.p12其中-chain指⽰同时添加证书链,-CAfile 指定了CA证书,导出的p12⽂件将包含多个证书。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

linux下利用openssl来实现证书的颁发(详细步骤)
1、首先需要安装openssl,一个开源的实现加解密和证书的专业系统。

在centos下可以利用yum安装。

2、openssl的配置文件是f,我们一般就是用默认配置就可以。

如果证书有特殊要求的话,可以修改配置适应需求。

这样必须把相关的文件放到配置文件指定的目录下面。

3、首先需要利用openssl生成根证书,以后的服务器端证书或者客户端证书都用他来签发,可以建立多个根证书,就像对应不同的公司一样
#生成根证书的私钥
openssl genrsa -out /home/lengshan/ca.key
#利用私钥生成一个根证书的申请,一般证书的申请格式都是csr。

所以私钥和csr一般需要保存好openssl req -new -key /home/lengshan/ca.key -out /home/lengshan/ca.csr
#自签名的方式签发我们之前的申请的证书,生成的证书为ca.crt
openssl x509 -req -days 3650 -in /home/lengshan/ca.csr -signkey
/home/lengshan/ca.key -out /home/lengshan/ca.crt
#为我们的证书建立第一个序列号,一般都是用4个字符,这个不影响之后的证书颁发等操作
echo FACE > /home/lengshan/serial
#建立ca的证书库,不影响后面的操作,默认配置文件里也有存储的地方
touch /home/lengshan/index.txt
#建立证书回收列表保存失效的证书
openssl ca -gencrl -out /home/lengshan/ca.crl -crldays 7
已上就完成了根证书的相关操作,下一步可以颁发证书了。

4、生成和签发服务器身份验证证书,注意证书是自签名的,浏览器会提示不受信任
#建立服务器验证证书的私钥
openssl genrsa -out /home/lengshan/server.key
#生成证书申请文件
openssl req -new -key /home/lengshan/server.key
-out /home/lengshan/server.csr
#利用根证书签发服务器身份验证证书
openssl ca -in /home/lengshan/server.csr -cert /home/lengshan/ca.crt -keyfile /home/lengshan/ca.key -out /home/lengshan/server.crt
至此,服务器端身份认证证书已经完成,可以利用证书和私钥生成pfx格式的证书给微软使用,命令如下:
openssl pkcs12 -export -clcerts -in /home/lengshan/server.crt -inkey
/home/lengshan/server.key -out
5、签发客户端身份认证证书
#生成私钥
openssl genrsa -des3 -out /home/lengshan/users/1/1.key 1024
#生成证书请求文件
openssl req -new -key /home/lengshan/users/1/1.key -out
/home/lengshan/users/1/1.csr
#签发证书
openssl ca -in /home/lengshan/users/1/1.csr -cert /home/lengshan/ca.crt
-keyfile /home/lengshan/users/1/1.crt
#生成pfx格式
openssl pkcs12 -export -clcerts -in /home/lengshan/users/1/1.crt -inkey
/home/lengshan/users/1/1.key -out /home/lengshan/users/1/1.p12
客户端证书完成,注意如果在web服务器上使用客户端证书,需要在web服务器上使用根证书对客户端进行验证,切记!。

相关文档
最新文档