如何建立一個私人的https


自己用 CA 簽自己的 certificate

  1. 先幫自己的 CA 生一組 key & certificate
  2. 幫自己的主機生一組 key & CSR
  3. 用自己的主機簽 CSR 讓他變成 certificate
openssl genrsa -des3 -out ca.key 4096

由於 CA 的 key 只有在簽 certificate 的時候會用到,不像 certificate 的 key 服務本身會用到,所以這邊可以加上 des3 ,會要你輸入一個密碼加密。

openssl req -x509 -new -nodes -key ca.key -sha256 -days 365 -out ca.crt

接下來我們幫 CA 生一組 certificate,通常這個天數會久不少。

openssl genrsa -out host.key 4096

這組是主機上的服務要用的 key ,就不加密了。

openssl req -new -key host.key -sha256 -out host.csr

最後來簽這個 CSR 產生 certificate

openssl x509 -req -in host.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out host.crt -days 30 -sha256
,