新聞中心
OpenSSL簡(jiǎn)介
OpenSSL是一種加密工具套件,可實(shí)現(xiàn)安全套接字層(SSL v2 / v3)和傳輸層安全性(TLS v1)網(wǎng)絡(luò)協(xié)議以及它們所需的相關(guān)加密標(biāo)準(zhǔn)。
為田家庵等地區(qū)用戶(hù)提供了全套網(wǎng)頁(yè)設(shè)計(jì)制作服務(wù),及田家庵網(wǎng)站建設(shè)行業(yè)解決方案。主營(yíng)業(yè)務(wù)為成都網(wǎng)站設(shè)計(jì)、做網(wǎng)站、成都外貿(mào)網(wǎng)站建設(shè)公司、田家庵網(wǎng)站設(shè)計(jì),以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專(zhuān)業(yè)、用心的態(tài)度為用戶(hù)提供真誠(chéng)的服務(wù)。我們深信只要達(dá)到每一位用戶(hù)的要求,就會(huì)得到認(rèn)可,從而選擇與我們長(zhǎng)期合作。這樣,我們也可以走得更遠(yuǎn)!openssl命令行工具用于從shell程序使用OpenSSL加密庫(kù)的各種加密功能。 它可以用于:
- 創(chuàng)建和管理私鑰,公鑰和參數(shù)
- 公鑰加密操作
- 創(chuàng)建X.509證書(shū),CSR和CRL
- 消息摘要的計(jì)算
- 使用密碼進(jìn)行加密和解密
- SSL / TLS客戶(hù)端和服務(wù)器測(cè)試
- 處理S / MIME簽名或加密的郵件
- 時(shí)間戳記請(qǐng)求,生成和驗(yàn)證
openssl配置文件及三種策略
配置文件
/etc/pki/tls/openssl.cnf
三種策略
match(匹配):要求申請(qǐng)?zhí)顚?xiě)的信息跟CA設(shè)置信息必須一致
optional(可選):可有可無(wú),跟CA設(shè)置信息可不一致
supplied(提供):必須填寫(xiě)這項(xiàng)申請(qǐng)信息
創(chuàng)建私有CA和申請(qǐng)、頒發(fā)證書(shū)文件(以下操作都是在一臺(tái)機(jī)器上執(zhí)行)
1.創(chuàng)建所需要的文件
[root@CentOS7 ~]# cd /etc/pki/CA/
[root@CentOS7 CA]# touch index.txt 生成證書(shū)索引數(shù)據(jù)庫(kù)文件
[root@CentOS7 CA]# echo 01 > serial 指定第一個(gè)頒發(fā)證書(shū)的序列號(hào)
2.CA自簽證書(shū)
2.1生成私鑰
[root@CentOS7 CA]# (umask 066;openssl genrsa -out private/cakey.pem 2048)
Generating RSA private key, 2048 bit long modulus
...................................................................................+++
.+++
e is 65537 (0x10001)
2.2生成自簽名證書(shū)
[root@CentOS7 CA]# openssl req -new -x509 -key private/cakey.pem -days 3650 -out cacert.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]:abc
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:hechunping
Email Address []:root@abc.com
選項(xiàng)說(shuō)明:
-new:生成新證書(shū)簽署請(qǐng)求
-x509:專(zhuān)用于CA生成自簽證書(shū)
-key:生成請(qǐng)求時(shí)用到的私鑰文件
-days n:證書(shū)的有效期限
-out /PATH/TO/SOMECERTFILE: 證書(shū)的保存路徑
3.頒發(fā)證書(shū)
3.1在需要使用證書(shū)的主機(jī)生成證書(shū)請(qǐng)求(本實(shí)驗(yàn)是在本機(jī))
3.1.1生成私鑰
[root@CentOS7 CA]# (umask 066;openssl genrsa -out /data/test.key 2048)
Generating RSA private key, 2048 bit long modulus
..................................................+++
...............................+++
e is 65537 (0x10001)
3.1.2生成證書(shū)申請(qǐng)文件
[root@CentOS7 CA]# openssl req -new -key /data/test.key -out /data/test.csr
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]:abc
Organizational Unit Name (eg, section) []:IT
Common Name (eg, your name or your server's hostname) []:hechunping
Email Address []:root@abc.com
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
3.2將證書(shū)申請(qǐng)文件傳輸給CA(兩臺(tái)不同的主機(jī)可以使用scp命令傳輸)
3.3CA簽署證書(shū),并將證書(shū)頒發(fā)給請(qǐng)求者
[root@CentOS7 CA]# openssl ca -in /data/test.csr -out certs/test.crt -days 100
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches the signature
Signature ok
Certificate Details:
Serial Number: 1 (0x1)
Validity
Not Before: Nov 10 13:45:34 2019 GMT
Not After : Feb 18 13:45:34 2020 GMT
Subject:
countryName = CN
stateOrProvinceName = beijing
organizationName = abc
organizationalUnitName = IT
commonName = hechunping
emailAddress = root@abc.com
X509v3 extensions:
X509v3 Basic Constraints:
CA:FALSE
Netscape Comment:
OpenSSL Generated Certificate
X509v3 Subject Key Identifier:
4C:AE:F0:13:F0:CD:8F:B5:F7:3F:1B:C8:E4:77:91:02:9E:88:6B:5A
X509v3 Authority Key Identifier:
keyid:E3:C1:5E:6D:94:5E:F2:AE:16:67:79:2C:69:B5:B9:10:D9:E0:51:BE
Certificate is to be certified until Feb 18 13:45:34 2020 GMT (100 days)
Sign the certificate? [y/n]:y
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
注意:默認(rèn)要求 countryName(國(guó)家),stateOrProvinceName(省),organizationName(公司)三項(xiàng)必須和CA一致
3.4查看證書(shū)中的信息
[root@CentOS7 CA]# openssl x509 -in certs/test.crt -noout -text|issuer|subject|serial|dates
3.5查看指定編號(hào)的證書(shū)狀態(tài)
[root@CentOS7 CA]# openssl ca -status 01
Using configuration from /etc/pki/tls/openssl.cnf
01=Valid (V)
4.吊銷(xiāo)證書(shū)
4.1在客戶(hù)端獲取要吊銷(xiāo)的證書(shū)的serial
[root@CentOS7 CA]# openssl x509 -in certs/test.crt -noout -serial -subject
serial=01
subject= /C=CN/ST=beijing/O=abc/OU=IT/CN=hechunping/emailAddress=root@abc.com
4.2在CA上,根據(jù)客戶(hù)提交的serial與subject信息,對(duì)比檢驗(yàn)是否與index.txt文件中的信息一致
[root@CentOS7 CA]# cat index.txt
V 200218134534Z 01 unknown /C=CN/ST=beijing/O=abc/OU=IT/CN=hechunping/emailAddress=root@abc.com
4.2.1吊銷(xiāo)證書(shū)
[root@CentOS7 CA]# openssl ca -revoke newcerts/01.pem
Using configuration from /etc/pki/tls/openssl.cnf
Revoking Certificate 01.
Data Base Updated
4.2指定第一個(gè)吊銷(xiāo)證書(shū)的編號(hào),注意:第一次更新證書(shū)吊銷(xiāo)列表前才需要執(zhí)行。
[root@CentOS7 CA]# echo 01 > crlnumber
4.3更新證書(shū)吊銷(xiāo)列表
[root@CentOS7 CA]# openssl ca -gencrl -out crl.pem
Using configuration from /etc/pki/tls/openssl.cnf
4.4查看crl文件
[root@CentOS7 CA]# openssl crl -in crl.pem -noout -text
將申請(qǐng)下來(lái)的證書(shū)導(dǎo)出到windows中查看
1.在windows上按"win+R"鍵,然后運(yùn)行"certmgr.msc"命令。
2.找到“受信任的根證書(shū)頒發(fā)機(jī)構(gòu)”右鍵單擊“所有任務(wù)”--->“導(dǎo)入”,然后按照向?qū)нx擇在Linux申請(qǐng)下來(lái)的證書(shū)。
3.查看證書(shū)信息
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。
文章題目:使用OpenSSL創(chuàng)建CA和申請(qǐng)證書(shū)-創(chuàng)新互聯(lián)
本文來(lái)源:http://www.ef60e0e.cn/article/cojdeg.html