前面的文章成功在 Apache2 設定 HTTPS 之後,接著要在 Tomcat 8 上也設定 HTTPS。
環境一樣是要用全新的 Tomcat,因此流程也會包含環境建置。
而金鑰跟憑證的部份跟前面一樣,由 Godaddy 給予的兩個檔案:fe461f1ba212ab7.crt 和 gd_bundle-g2-g1.crt
以及事先產生好的金鑰檔 my-private-key.key。
Software entities (class, modules, functions, etc.) should be open for extension, but closed for modification. Junior programmers create simple solutions to simple problems. Senior programmers create complex solutions to complex problems. Great programmers find simple solutions to complex problems. 註1:本部落格的範例程式碼在 2015 年以前的文章中,大多是以全型空白做縮排。如需服用,請自行用文字編輯器的取代功能把全型空白取代成半型空白。
- Bertrand Meyer
- Charles Connell
註2:本部落格的內容授權請參閱部落格底部的授權宣告。
2016年10月20日 星期四
在全新的 Tomcat 8 設定 HTTPS
在全新的 Apache 2.4 設定 HTTPS
在完成跟 GoDaddy 申請憑證之後,Godaddy 網站上可以取得兩個 CRT 檔
我這邊拿到的,一個是命名很像亂碼的 fe461f1ba212ab7.crt 檔案,另一個則是 gd_bundle-g2-g1.crt。
fe461f1ba212ab7.crt 這個檔案是 SSL Certificate File,而 gd_bundle-g2-g1.crt 則是 SSL Certificate Chain File
加上申請憑證前,我們需要自行先產生的金鑰,假設檔名是 my-private-key.key
總共有三個檔案,就可以完成 Apache 2.4 的 HTTPS 設定了。
2016年8月24日 星期三
Apache 2 SSL 的 Passphrase 問題
在 Apache 2 裡,如果要使用有被 Passphrase 保護的 key 給 SSL 使用
必須在某處提供 SSL 的 Passphrase 才能讓 Apache 正常啟動。
一般內建的方法是使用 builtin,也就是 Apache 啟動時會直接詢問使用者
其他方法則是可以把 Passphrase 寫在某個檔案裡,要 Apache 啟動時去讀取。
而寫設定的地方,在我的 container 中是放在 /etc/apache2/mods-enabled/ssl.conf 裡。
如果是不想那麼麻煩地處理 Passphrase 問題,想把他從金鑰中移掉
則可以參考 [2] 的方法,只需要指定輸入和輸出的金鑰檔名,然後輸入 Passphrase
就可以重製出一個不需要 Passphrase 的金鑰了。
以 RSA 的金鑰來說,指令如下:
openssl rsa -in /path/to/your/rsakey.key -out /path/to/your/rsa.nocrypt.key
參考資料
2016年8月9日 星期二
(書籤) SSL 憑證
參考資料:
- [筆記] SSL 憑證購買記
- 憑證簽章要求 (CSR) 產生說明 - Apache SSL
- OpenSSL - 金鑰與憑證的管理
- 使用 openssl 產生 SSL 電子證書
- Apache Requires SSL / Passphrase
- Difference between OpenSSL and keytool
- OpenSSL 操作筆記 - 檔案格式轉換
- Difference between trustStore and keyStore in Java – SSL
- How to add or list certificates from keystore or trustStore in Java - Keytool Example
- Re:[問題] URLConnection 產生了HTTP 405 Exception [Re:piaoyi]