會有這種需求是因為購買憑證需要簽單,VM因安全因素只開443port所以只能變通一下用 自簽憑證 來解決這個問題,但這樣做也是有好處的,正式憑證下來後直接換CRT檔,就可以快速起用新憑證。
啟用 apache ssl 模組
指令:sudo a2enmod ssl
發行自簽憑證
指令:openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /home/jeff/apache.key -out /home/jeff/apache.crt
指令說明 產生憑證 key 與 crt 有效期限為 365天 使用 2048位元 rsa加密
下完指令後輸入相關資訊
Country Name (2 letter code) [AU]:TW //國家簡碼 TW
State or Province Name (full name) [Some-State]:Taiwan //完整國家名稱
Locality Name (eg, city) []:New Taipei //城市名稱
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Webteach //組織(公司)名稱
Organizational Unit Name (eg, section) []:IT //單位(部門)名稱
Common Name (e.g. server FQDN or YOUR name) []:www.webteach.tw //憑證名稱 建議填網址(有可能同主機多個ssl)
Email Address []:test@gmail.com.tw //聯絡Email請填真的可通訊的Email
但因為是自簽憑證的關係,上面的隨便填也不會怎樣><
修改 apache ssl 設定
指令:sudo vi /etc/apache2/sites-available/default-ssl.conf
修改設定檔中的這兩行
SSLCertificateFile /home/jeff/apache.crt
SSLCertificateKeyFile /home/jeff/apache.key
啟用 apache ssl 設定
指令:sudo a2ensite default-ssl.conf
重啟apache
指令:sudo service apache2 restart
最後開啟瀏覽器 輸入,https://你的網址
但由於你的主機非可信認的第三方發證機構所以 會出現 你的連接不是私人的(Your connection is not private)
This server could not prove that it is yourweburl; its security certificate is not trusted by your computer’s operating system. This may be caused by a misconfiguration or an attacker intercepting your connection.
Proceed to yourweburl (unsafe)<=就點這個吧
3M 日本原裝進口 速效型 防水噴霧 170ml 衣物 鞋子 皮革 透氣 防水 團購
維力 素飄香 野菜多 素排骨雞 素紅燒牛肉 麻辣燙 麻油當歸枸杞 蔘湯麵 素食 泡麵 單包
味丹 隨緣 鮮蔬百匯/素肉骨茶/素魷魚羹麵/韓式泡菜/麻辣燙湯麵 (5包/袋) 素食 全素 泡麵
我最牛-綜合牛角酥餅乾