本文章對應(yīng)的文檔:使用OpenSSL創(chuàng)建生成CA證書服務(wù)器客戶端證書及密鑰資源-CSDN文庫
https://download.csdn.net/download/weixin_41885845/88746920
對于SSL單向認(rèn)證
服務(wù)器需要CA證書、server證書、server私鑰,客戶端需要CA證。
對于SSL雙向認(rèn)證
服務(wù)器需要CA證書、server證書、server私鑰,客戶端需要CA證書,client證書、client私鑰。
?
生成CA證書
私鑰生成指令: openssl genrsa
該命令是會用來生成 RSA 私有秘鑰,不會生成公鑰,因?yàn)楣€提取自私鑰。
openssl? genrsa [-out filename] [-passout arg] [-f4] [-3] [-rand file(s)] [-engine id] [numbits] [-des] [-des3] [-idea]
-des??????????? encrypt the generated key with DES in cbc mode
?-des3?????????? encrypt the generated key with DES in ede cbc mode (168 bit key)
?-idea?????????? encrypt the generated key with IDEA in cbc mode
?-seed
???????????????? encrypt PEM output with cbc seed
?-aes128, -aes192, -aes256
???????????????? encrypt PEM output with cbc aes
?-camellia128, -camellia192, -camellia256
???????????????? encrypt PEM output with cbc camellia
?-out file?????? output the key to 'file
?-passout arg??? output file pass phrase source
?-f4???????????? use F4 (0x10001) for the E value
?-3????????????? use 3 for the E value
?-engine e?????? use engine e, possibly a hardware device.
?-rand file:file:...
???????????????? load the file (or the files in the directory) into
???????????????? the random number generator
-des ??????????? 使用des cbc模式對私鑰文件進(jìn)行加密。
-des3 ?????????? 使用des3 cbc模式對私鑰文件進(jìn)行加密。
-idea ?????????? 使用idea cbc模式對私鑰文件進(jìn)行加密。
-aes128, -aes192, -aes256 ????????????? 使用aes cbc模式對私鑰文件進(jìn)行加密。
-out file ?????? 指定輸出私鑰文件名。
-f4??????????????????????? 指定F4做為E值,默認(rèn)。
-3 ?????????????????????? 指定3做為E值。
-seed arg ??????????? 指定cbc的隨機(jī)種子。
-rand file:file 指定隨機(jī)數(shù)種子文件。
———————————————————————————————————————
-out filename :將生成的私鑰保存至filename文件,若未指定輸出文件,則為標(biāo)準(zhǔn)輸出。
????????????????????????????????????
-numbits :指定要生成的私鑰的長度(單位 bit),默認(rèn)為1024。該項(xiàng)必須為命令行的最后一項(xiàng)參數(shù)。
-des|-des3|-idea:指定加密私鑰文件用的算法,這樣每次使用私鑰文件都將輸入密碼,太麻煩所以很少使用。
-passout args :加密私鑰文件時,傳遞密碼的格式,如果要加密私鑰文件時單未指定該項(xiàng),則提示輸入密碼。傳遞密碼的args的格式見openssl密碼格式。
測試
1、 openssl genrsa -seed -out rs_pri.pem 512
?
2、 openssl genrsa -aes256 –out rs_pri.key 512
?
3、 openssl genrsa -des3 -out test.key? -rand hello.txt 512
?
4 、openssl genrsa -des -passout pass:"123456" -out prikey.pem 1024
請求CA證書(先創(chuàng)建CA證書私鑰)
C-----國家(Country Name)
ST----省份(State or Province Name)
L----城市(Locality Name)
O----公司(Organization Name)
OU----部門(Organizational Unit Name)
CN----產(chǎn)品名(Common Name)
emailAddress----郵箱(Email Address)
req指令
主要用于創(chuàng)建證書請求文件;
openssl req [options] <infile> outfile
-inform arg ???????? ????指定輸入文件格式,可以為DER或PEM,默認(rèn)為PEM。
-outform arg ???????????? 指定輸出文件格式,可以為DER或PEM,默認(rèn)為PEM。
-in arg ??????????????? ????指定輸入文件。
-out arg ???????????????????? 指定輸出文件。
-new ???????????????????????? 創(chuàng)建新的證書請求文件。
-key file ????????????? ????指定創(chuàng)建證書請求的私鑰文件。
-keyform arg ???????????? 指定創(chuàng)建證書請求的私鑰文件的格式,可以為DER或PEM,默認(rèn)為PEM。
-passin arg ???????? ????指定私鑰文件的口令保護(hù)來源。
-verify ???????????????? ????校驗(yàn)證書請求文件的主體簽名是否有效。
-noout ?????????????????????? 不打印證書請求信息。
-text ????????????????????????? 文本打印證書請求文件。
-modulus ?????????????????? 輸出證書請求的模數(shù)信息。
-subject ???????????????????? 輸出證書請求主體信息。
-subj arg ??????????????????? 設(shè)置或修改證書請求的主體信息。
-multivalue-rdn ? 設(shè)置或修改證書請求的主體信息時,允許多RDN格式。
-utf8 ????????????????????????? 輸入字符為utf8編碼,默認(rèn)輸入為ASCII編碼。
-[digest] ??????????????????? 指定創(chuàng)建證書請求的摘要算法。
-pubkey ???????????????????? 提取證書請求文件中的公鑰。
x509指令
主要用于創(chuàng)建、修改x509證書。
openssl x509 [options] <infile >outfile
-inform arg ???????? ?????? 指定輸入文件格式,可以為DER或PEM,默認(rèn)為PEM。
-outform arg ???????????? 指定輸出文件格式,可以為DER或PEM,默認(rèn)為PEM。
-keyform arg ???????????? 指定私鑰文件格式,可以為DER或PEM,默認(rèn)為PEM。文章來源:http://www.zghlxwxcb.cn/news/detail-804764.html
-CAform arg ????????????? 指定CA文件格式,可以為DER或PEM,默認(rèn)為PEM。文章來源地址http://www.zghlxwxcb.cn/news/detail-804764.html
<
到了這里,關(guān)于【全】OpenSSL創(chuàng)建生成CA證書、服務(wù)器、客戶端證書及密鑰說明的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!