a打头的linux证书,ca 颁发证书

ca 颁发证书

9f29eb95c5872a0f7030dcba2bfd5aca.png

创建CA和申请证书:

证书默认配置文件:

####################################################################

[ ca ]

default_ca = CA_default # The default ca section

####################################################################

[ CA_default ]

dir = /etc/pki/CA # Where everything is kept

certs = $dir/certs # Where the issued certs are kept

crl_dir = $dir/crl # Where the issued crl are kept

database = $dir/index.txt # database index file.

#unique_subject = no # Set to 'no' to allow creation of

several ctificates with same subject.

new_certs_dir = $dir/newcerts # default place for new certs.

certificate = $dir/cacert.pem # 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/private/cakey.pem# The private key

RANDFILE = $dir/private/.rand # private random number file

x509_extensions = usr_cert # The extentions to add to the cert

574515d4459bc21577a835c5e88d8ee7.png

7692b022629ca3f8b2c234a409bfcba6.png

adade47fec2e1108505ece56769e9b61.png

1fa982d03ab13f318696576889e90a77.png

[root@node01 ~]# hostname -i node01 #客户端

192.168.100.10

[root@node02 ~]# hostname -i node02 #服务器

192.168.100.20

ca默认配置文件:/etc/pki/tls/openssl.cnf

1、生成私钥:

[root@node02 CA]# touch /etc/pki/CA/index.txt

[root@node02 CA]# echo 01 > /etc/pki/CA/serial

[root@node02 CA]# (umask066; openssl genrsa -out /etc/pki/CA/private/cakey.pem 2048)

-bash: umask066: command not found

Generating RSA private key, 2048 bit long modulus

.+++

.............................................................................................................................................................................................................+++

8cd1704a700b8698313156cfa2d4e2ed.png

8b6bcd58cde06ea63b8e07e0dc6c5818.png

2、生成自签名证书:

[root@node02 CA]# openssl req -new -x509 -key /etc/pki/CA/private/cakey.pem -days 3650 -out /etc/pki/CA/cacer.pem

You are about to be asked to enter information that will be incorporated

into 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 blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

Country Name (2 letter code) [XX]:CN

State or Province Name (full name) []:beijing

Locality Name (eg, city) [Default City]:beijing

Organization Name (eg, company) [Default Company Ltd]:magedu

Organizational Unit Name (eg, section) []:opt

Common Name (eg, your name or your server's hostname) []:ca.magedu.com

Email Address []:admin@magedu.com

bb49a890703c6879d55faa6b5fbc9e65.png

3、查看证书内容:

[root@node02 CA]# openssl x509 -in cacer.pem -noout -text

fd30da5366b5d29f717c40632c58e659.png

4、windows 查看 cacer.pem 证书:

d9dad759ddf6c90c3c52323c8b7674bf.png

5、windows/mac 证书安装:

windows:

证书:

80326aeedec71552589d9894e2d26423.png

6adf3c3e0553d29f14e5700ae7dd50f2.png

验证:

39f9dd852443d32b1af9bf1ab96c4a9d.png

6、颁发证书:

1、生成私钥:

[root@node01 app]# ( umask 066; openssl genrsa -out app.key 2048)

ed878a1c9435b919f7bf4a2f73fdc946.png

2、生成证书申请文件

[root@node01 app]# openssl req -new -key app.key -days 365 -out app.csr

465dd0446558f56ea2fb04431b70697d.png

7、拷贝证书申请文件到node02 /etc/pki/CA

[root@node01 app]# scp ./app.csr node02:/etc/pki/CA/

dc496bc2b3ada3000bf881bad5d0964b.png

8、颁发证书的时候出现的报错信息:

[root@node02 CA]# openssl ca -in app.csr -out app.cer -days 100

Using configuration from /etc/pki/tls/openssl.cnf

Error opening CA certificate /etc/pki/CA/cacert.pem

140251176069008:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('/etc/pki/CA/cacert.pem','r')

140251176069008:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:

64f5e45d2db3aacd3332cb968933d7b4.png

[root@node02 CA]# mv cacer.pem cacert.pem

9、CA签署证书,并将证书颁发给请求者

[root@node02 CA]# openssl ca -in app.csr -out app.cer -days 100

7cc18b1f7a6afaab482a1507778e0a4e.png

592fca386ed1b44dee3725405c903688.png

59431f4bd535b3280bccaffb215e67d6.png

最后证书导入浏览器或者对应app 服务网站;

8977d010a0c480f5d1e31efbc927ebc1.png

ca 可以颁发多证书:

[root@node02 CA]# (umask 066; openssl genrsa -out /etc/pki/tls/private/test.key 2048)

[root@node02 CA]# openssl req -new -key /etc/pki/tls/private/test.key -out test.csr

ecf6fcded0befd5991be595623e0c665.png

[root@node02 CA]# vim /etc/pki/tls/openssl.cnf

ab83cc1fbc73cf8ba7c2796bcae6b969.png

f8eeb6f7b5b336f343494560d95e3bab.png

[root@node02 CA]# openssl ca -in ./test.csr -out test.cer -days 300

01abe8334eedc59e3be2739ed49f44b0.png

同一个证书请求 或者多个证书:

[root@node02 CA]# openssl ca -in ./app.csr -out app.cer -days 300

a72c2bd65f9bc7635473f0355b41062b.png

[root@node02 CA]# cat index.txt.attr

unique_subject = yes

72b27f1963928aba7b8dc4568affec56.png

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值