openssl產生https認證 (轉)

來源:互聯網
上載者:User

標籤:open   base   rtu   apache   出錯   access   blog   檔案   發送   

openssl genrsa -des3 -out server.key 1024
運行時會提示輸入密碼,此密碼用於加密key檔案
去除key檔案口令的命令:
openssl rsa -in server.key -out server.key

2.openssl req -new -key server.key -out server.csr -config openssl.cfg
產生Certificate Signing Request(CSR),產生的csr檔案交給CA簽名後形成服務端自己的認證.螢幕上將有提示,依照其指示一步一步輸入要求的個人資訊即可.

3.對用戶端也作同樣的命令產生key及csr檔案:
openssl genrsa -des3 -out client.key 1024
openssl req -new -key client.key -out client.csr -config openssl.cfg

4.CSR檔案必須有CA的簽名才可形成認證.可將此檔案發送到verisign等地方由它驗證.自己產生:
openssl req -new -x509 -keyout ca.key -out ca.crt -config openssl.cfg

5.用產生的CA的認證為剛才產生的server.csr,client.csr檔案簽名:
Openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config openssl.cfg
Openssl ca -in client.csr -out client.crt -cert ca.crt -keyfile ca.key -config openssl.cfg

 

PS:如報update database之類的錯誤,把index.txt.attr 檔案內容更新為 unique_subject = no

注意: 此時會出錯:Using configuration from /usr/share/ssl/openssl.cfg I am unable to access the ./demoCA/newcerts directory ./demoCA/newcerts: No such file or directory 
解決方案: 1).mkdir -p ./demoCA/newcerts 
          2).touch demoCA/index.txt 
         3).touch demoCA/serial 
        4).echo 01 > demoCA/serial

6.合并認證檔案(crt)和私密金鑰檔案(key)

1).cat client.crt client.key > client.pem

2).cat server.crt server.key > server.pem

7.合并成pfx認證

1).openssl pkcs12 -export -clcerts -in client.crt -inkey client.key -out client.p12 
2).openssl pkcs12 -export -clcerts -in server.crt -inkey server.key -out server.p12 
8.文本化認證

1).openssl pkcs12 -in client.p12 -out client.txt

2).openssl pkcs12 -in server.p12 -out server.txt

9.螢幕模式顯式:(認證、私密金鑰、公開金鑰)

1).openssl x509 -in client.crt -noout -text -modulus

2).openssl rsa -in server.key -noout -text -modulus

3).openssl rsa -in server.pub -noout -text -modulus

10.得到DH

1).openssl dhparam -out dh1024.pem 1024


(8) 編輯apache的設定檔httpd.cfg
開啟: LoadModule ssl_module modules/mod_ssl.so
去掉以下語句的注釋, Include conf/extra/httpd-ssl.cfg
# Secure (SSL/TLS) connections
Include conf/extra/httpd-ssl.cfg
#    
(9) 編輯 conf/extra/httpd-ssl.cfg

<VirtualHost *:443>
   SSLEngine On
   SSLCertificateFile conf/ssl/server.crt
   SSLCertificateKeyFile conf/ssl/server.key
   SSLCertificateChainFile conf/ssl/ca.crt
</VirtualHost> 

cd /usr/local/apache/conf
openssl genrsa -des3 -out server.key 1024
openssl req -new -key server.key -out server.csr -config /usr/local/ssl/openssl.cfg 
openssl req -new -x509 -keyout ca.key -out ca.crt -config /usr/local/ssl/openssl.cfg 
mkdir -p ./demoCA/newcerts 
touch demoCA/index.txt
touch demoCA/serial
echo 01 > demoCA/serial
openssl ca -in server.csr -out server.crt -cert ca.crt -keyfile ca.key -config /usr/local/ssl/openssl.cfg 
bin/apachectl start

openssl產生https認證 (轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.