Tomcat サーバでSSLを構成する方法
SSLを使用してプロジェクトをデプロイするには、SSLをサポートするようにOpenLegacy ApacheTomcatサーバーを構成する必要があります
手順
JAVAでKEYSTOREファイルの作成
コマンドラインから次のコマンドを実行します:
cd %JAVA_HOME%/bin keytool -genkey -alias tomcat -keyalg RSA
上記のコマンドを入力すると、いくつかの質問が表示されます。 まず、パスワード(“password“など)を作成します。
次の例のように、Enterキーを押して続行し、次の質問に答えます。:
Enter Keystore password: password
Re-enter new password: password
What is your first and last name?
[Unknown]: Avi Zehavi
What is the name of your organizational unit?
[Unknown]: QA
What is the name of your organization?
[Unknown]: OpenLegacy
What is the name of your City or Locality?
[Unknown]: Petah Tikva
What is the name of your State or Province?
[Unknown]: Israel
What is the two-letter country code for this unit?
[Unknown]: IL
Is CN= Avi Zehavi, OU=QA, O=OpenLegacy, L= Petah Tikva, ST=Israel, C=IL correct?
[no]: yes
If needed, enter key password for
(RETURN if same as Keystore password): password
Re-enter new password: password
結果、ホームディレクトリに .keystore ファイルが作成されます。
.KEYSTORE ファイルでAPACHE TOMCATを構成します
Tomcatインストールディレクトリでい、 conf フォルダーを開きます。server.xml ファイルがあります。このファイルで次の宣言文を見つけます。
<!-- <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" /> -->
次の宣言文に置き換えます:
<Connector SSLEnabled="true" acceptCount="100" clientAuth="false" disableUploadTimeout="true" enableLookups="false" maxThreads="25" port="8443" keystoreFile="full path to keystore/.keystore" keystorePass="password" protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="https" secure="true" sslProtocol="TLS" />
重要: ホームディレクトリのKeystore ファイルを keystoreFile で更新してください。例: C:/Users/eduar/.keystore
テストをします
OpenLegacy サーバサービスを再起動し、次へアクセス https://localhost:8443。Tomcatのローカルホームページが確認できます。
関連情報