开始签发:

报错1:缺少CA的私钥

[root@CA ~]# openssl ca -in web.csr -out web.crt
Using configuration from /etc/pki/tls/openssl.cnf
Error opening CA private key /etc/pki/CA/private/cakey.pem
140183854000032:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('/etc/pki/CA/private/cakey.pem','r')
140183854000032:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:
unable to load CA private key

解决:

[root@CA ~]# openssl genrsa 1024 > /etc/pki/CA/private/cakey.pem

报错2:缺少CA的自签名证书

[root@CA ~]# openssl ca -in web.csr -out web.crt
Using configuration from /etc/pki/tls/openssl.cnf
Error opening CA certificate /etc/pki/CA/cacert.pem
139803183761312:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('/etc/pki/CA/cacert.pem','r')
139803183761312:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:
unable to load certificate

解决:

[root@CA ~]# openssl req -new -key /etc/pki/CA/private/cakey.pem -days 3650 -x509 -out /etc/pki/CA/cacert.pem
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:BJ
Locality Name (eg, city) [Default City]:BJ
Organization Name (eg, company) [Default Company Ltd]:XXXX
Organizational Unit Name (eg, section) []:web
Common Name (eg, your name or your server's hostname) []:172.16.12.96
Email Address []:xxxx@163.com

报错3:缺少索引文件

[root@CA ~]# openssl ca -in web.csr -out web.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'
139734688642976:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('/etc/pki/CA/index.txt','r')
139734688642976:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:

解决:

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

报错4:缺少序列号文件

[root@CA ~]# openssl ca -in web.csr -out web.crt
Using configuration from /etc/pki/tls/openssl.cnf
/etc/pki/CA/serial: No such file or directory
error while loading serial number
140469450205088:error:02001002:system library:fopen:No such file or directory:bss_file.c:402:fopen('/etc/pki/CA/serial','r')
140469450205088:error:20074002:BIO routines:FILE_CTRL:system lib:bss_file.c:404:

解决:

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

然后就可以签名了

[root@CA ~]# openssl ca -in web.csr -out web.crt
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐