知道localhost也可以使用https很久了,但是一直卡在環境安裝和使用,因為真的需要本地端測試憑證了,就定下心來測試,一般會查到使用mkcert和openssl兩種方式,各有千秋
第一種使用openssl的方式,優點是不用多安裝mkcert,但是設定檔沒有參考的話,應該產生不了,https://blog.miniasp.com/post/2019/02/25/Creating-Self-signed-Certificate-using-OpenSSL
openssl req -x509 -new -nodes -sha256 -utf8 -days 3650 -newkey rsa:2048 -keyout server.key -out server.crt -config ssl.conf
openssl pkcs12 -export -in server.crt -inkey server.key -out server.pfx
可以手動匯入,也可以自動匯入,記得使用管理者權限
certutil -addstore -f “ROOT” server.crt
第二種是很容易查到的mkcert,安裝稍微麻煩,但是設定相對簡單
https://www.cnblogs.com/googlegis/p/14976720.html
設定domain的話,用下列方式
mkcert example.com “*.example.com” localhost 127.0.0.1 ::1
不想那麼麻煩可以用ip
mkcert 192.168.8.100
產生的key pem檔改副檔名
pkcs12 -export -out server.pfx -in server.pem -inkey server.key
兩種方法都要產生pfx匯入IIS,其它的web server就參考連結,因為IIS的比較少人弄,所以我的測試用IIS
import
留言