此方式僅爲個人簽名的SSL證書, 個人簽名的版本是不受公網路由信任的,最直接的影響是打開個人簽名的https網站時,頁面會提示"此網站不受信任,是否添加例外"之類的警告,點擊add exception 之後纔會訪問進去.
而更嚴重的影響是,在service層面. 前端發送異步請求到service, 使用個人簽名證書的service是無法被https的前端頁面(注意: HTTPS的前端頁面不能訪問http 後端service)調用或訪問的. 前端頁面的控制檯會報錯.
這裏又涉及到另一個點, 與這個問題無關,但也需要掌握,即 瀏覽器的通遠策略, 可參考https://developer.mozilla.org...
回到我們這個問題, 首先, 將路徑切換到$JAVA_HOME/bin目錄,
keytool -genkey -keyalg RSA -keysize 2048 -keystore /home/XXX.jks
注意, 此時需要輸入此keystore的密碼.
密碼長度爲至少6位
Enter keystore password:
Keystore password is too short - must be at least 6 characters
Enter keystore password:
Re-enter new password:
輸入密碼後,下一步需輸入一些與此key相關的信息.
需要注意的部分是first and last name, 因爲它表示應用這個證書的域名
What is your first and last name?
[Unknown]: XXX.XX.com
What is the name of your organizational unit?
[Unknown]: XX
What is the name of your organization?
[Unknown]: XX
What is the name of your City or Locality?
[Unknown]: Dalian
What is the name of your State or Province?
[Unknown]: CN
What is the two-letter country code for this unit?
[Unknown]: CN
Is CN=XXX.com, OU=XX, O=XX, L=Dalian, ST=CN, C=CN correct?
[no]: y
最後一步, 密碼置空直接回車即可
Enter key password for <mykey>
(RETURN if same as keystore password):
這樣, 在指定的目錄下,jks證書已經被生成出來了.