執行過程需要的資訊,其中:
COMMON NAME 為網域名稱(FQDN),如: star.im.chu.edu.tw
pass 為自設密碼
其餘為組織和機關的名稱和城市資料
step 1: 產生私用key (private key)(常用檔名: private.pem 或 server.key)(長度可用: 4096 或 2048; 以下的長度需一致)
代碼: 選擇全部
openssl genrsa -out server.key 4096
代碼: 選擇全部
openssl req -new -sha256 -key server.key -out server.csr
openssl req –new –newkey rsa:2048 –nodes –keyout server.key –out server.csr
openssl req -new -newkey rsa:4096 -nodes -out star_im_chu_edu_tw.csr -keyout star_im_chu_edu_tw.key -subj "/C=TW/ST=Taiwan/L=Hsinchu/O=CHU/OU=IM/CN=star.im.chu.edu.tw"
step 1+2: 可以同時完成1和2
代碼: 選擇全部
openssl req -new -sha256 -nodes -newkey rsa:4096 -keyout server.key -out server.csr
openssl req -x509 -sha256 -nodes -newkey rsa:4096 -keyout server.key -days 730 -out server.pem
step 4: prepare x509.ext
step 4: my CA 自已當CA 認證核發單位
代碼: 選擇全部
openssl req -new -sha256 -nodes -newkey rsa:4096 -keyout CA.key -out CA.csr
openssl x509 -req -sha256 -extfile x509.ext -extensions ca -in CA.csr -signkey CA.key -days 1095 -out CA.pem
openssl req -new -sha256 -nodes -newkey rsa:4096 -keyout server.key -out server.csr
openssl x509 -req -sha256 -CA CA.pem -CAkey CA.key -days 730 -CAcreateserial -CAserial CA.srl -extfile x509.ext -extensions server -in server.csr -out server.pem
代碼: 選擇全部
openssl x509 -in server.pem -noout -text
openssl req -in server.csr -noout -text
private.pem === server.key === server.pem (private key)
x509.ext 檔案參考設定
代碼: 選擇全部
[ ca ]
# X509 extensions for a ca
keyUsage = critical, cRLSign, keyCertSign
basicConstraints = CA:TRUE, pathlen:0
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid:always,issuer:always
[ server ]
# X509 extensions for a server
keyUsage = critical,digitalSignature,keyEncipherment
extendedKeyUsage = serverAuth,clientAuth
basicConstraints = critical,CA:FALSE
subjectKeyIdentifier = hash
authorityKeyIdentifier = keyid,issuer:always
代碼: 選擇全部
openssl req -x509 -out localhost.crt -keyout localhost.key \
-newkey rsa:2048 -nodes -sha256 \
-subj '/CN=localhost' -extensions EXT -config <( \
printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
代碼: 選擇全部
openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256
代碼: 選擇全部
SSLCertificateKeyFile "${SRVROOT}/conf/localhost.key"
SSLCertificateFile "${SRVROOT}/conf/localhost.crt"
修護錯誤
代碼: 選擇全部
AH01906: localhost:443:0 server certificate is a CA certificate (BasicConstraints: CA == TRUE !?)
pass 部份直接按 [enter], 為了方便測試使用不同的key和crt (或cert) 檔名
代碼: 選擇全部
openssl genrsa -out notEncodedPk.key 3072
openssl req -new -out website.csr -sha256 -key notEncodedPk.key
openssl x509 -req -in website.csr -days 365 -signkey notEncodedPk.key -out website.crt -outform PEM