■ 設定環境
+ Windows10
+ Tomcat-8.5.3 ... ※ Tomcat-8.5.20 でも試して動作確認。
+ JDK1.8
[b-1] 「a. キーストアを作成する」で作成したキーストアファイルをTomcat配下に置く
→ 例「C:\pg\apache-tomcat-8.5.3\conf\demo.keystore」
[b-2] 「【Tomcatがある環境】\apache-tomcat-X.X.XX\conf\server.xml」をエディタで開く
→ 例「C:\pg\apache-tomcat-8.5.3\conf\server.xml」をメモ帳で開く
[b-3] 以下を追加(「Connector port="8443"」などで検索すればヒットすると思うので、その付近に追加)
■構文
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" defaultSSLHostConfigName="【ホスト名】">
<SSLHostConfig hostName="【ホスト名】">
<Certificate
certificateKeystoreFile="【キーストアファイルの位置】"
certificateKeystorePassword="【キーストアファイルのパスワード】"
certificateKeyAlias="【キーストア内での証明書の名称】"
certificateKeystoreProvider="SUN"
certificateKeystoreType="JKS"
type="RSA" />
</SSLHostConfig>
</Connector>
* 修正例:server.xml
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443
This connector uses the NIO implementation with the JSSE engine. When
using the JSSE engine, the JSSE configuration attributes must be used.
-->
<!--
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true">
<SSLHostConfig>
<Certificate certificateKeystoreFile="conf/localhost-rsa.jks"
type="RSA" />
</SSLHostConfig>
</Connector>
-->
<!-- ★ここから★ -->
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" defaultSSLHostConfigName="localhost">
<SSLHostConfig hostName="localhost">
<Certificate
certificateKeystoreFile="conf/demo.keystore"
certificateKeystorePassword="changeit"
certificateKeyAlias="tomcat"
certificateKeystoreProvider="SUN"
certificateKeystoreType="JKS"
type="RSA" />
</SSLHostConfig>
</Connector>
<!-- ★ここまで★ -->
<!-- Define a SSL/TLS HTTP/1.1 Connector on port 8443 with HTTP/2
This connector uses the APR/native implementation. When using the
APR/native implementation or the OpenSSL engine with NIO or NIO2 then
the OpenSSL configuration attributes must be used.
-->
c.確認作業
[c-1] Tomcatを起動する
[c-2] 確認としてブラウザで以下のURLにアクセスする
=> Tomcat画面が表示されてたらOK
[[
https://localhost:8443/]]
■ トラブル
起動時にエラーはなくHTTPでは動いているが、SSLでつながない場合
以下を確認してみる
* キーストアがうまく作成できていない
* キーストアのパスワードが間違っている