若要使用 Keytool 來建立金鑰儲存庫,首先必須在金鑰儲存庫中建立一對金鑰組。 比方說,如果輸入下列指令行:
keytool -genkey -alias httpadapter -keystore c:\security\keystore
Keytool 會立即提示您輸入密碼。 可以輸入您自行選擇的密碼 (在 Keytool 參數內), 但應該將 Keytool 中輸入的密碼指定為 SSL 』 KeyStorePassword 連接器內容的值。 如需進一步資訊,請參閱KeyStorePassword。
此範例指令會在 c:\security\keystore 目錄中建立命名為 keystore 的金鑰儲存庫。 因此,您應該輸入 c:\security\keystore 作為 SSL 』 KeyStore 連接器階層式內容的值。 在上述指令行範例中,也請輸入 -alias httpadapter 作為 SSL 』 KeyStoreAlias 連接器階層式內容的值。 接著,Keytool 公用程式會提示您指定憑證的詳細資料。 以下說明您在每一項提示上可能輸入的答案。(請參閱 Keytool 文件。)
What is your first and last name? [Unknown]: HostName What is the name of your organizational unit? [Unknown]: wbi What is the name of your organization? [Unknown]: IBM What is the name of your City or Locality? [Unknown]: Burlingame What is the name of your State or Province? [Unknown]: CA What is the two-letter country code for this unit? [Unknown]: US Is <CN=HostName, OU=wbi, O=IBM, L=Burlingame, ST=CA, C=US> correct? [no]: yes
然後,Keytool 會提示您輸入密碼:
Enter key password for <httpadapter> (RETURN if same as keystore password):
請按 Return 來使用相同密碼。若要使用自簽憑證,您可能希望匯出上述建立的憑證。 在此情況下,請在指令行輸入下列指令:
keytool -export -alias httpadapter -keystore c:\security\keystore -file wsadapter.cer