3.3. Apache Karaf コンテナーで Undertow の SSL/TLS を有効化
以下の手順では、キーストアパスワード StorePass およびキーパスワード KeyPass で、署名済みの X.509 証明書と秘密鍵のペアがキーストアファイル alice.ks で作成済みであることを前提とします。
Karaf コンテナーで Undertow の SSL/TLS を有効にするには、以下を実行します。
Pax Web サーバーが、
etc/undertow.xmlファイルから設定を取得するように設定されていることを確認します。etc/org.ops4j.pax.web.cfgファイルの内容を確認すると、以下の設定があるはずです。org.ops4j.pax.web.config.file=${karaf.etc}/undertow.xmlテキストエディターで
etc/org.ops4j.pax.web.cfgファイルを開き、以下の行を追加します。org.osgi.service.http.port.secure=8443 org.osgi.service.http.secure.enabled=trueetc/org.ops4j.pax.web.cfgファイルを保存して閉じます。-
テキストエディターで
etc/undertow.xmlファイルを開きます。次の手順では、インストール時以降、変更されていないデフォルトのundertow.xmlファイルで作業することを前提としています。 XML 要素
http-listenerおよびhttps-listenerを検索します。http-listener要素をコメントアウトし (<!--および-->で囲み)、https-listener要素をアンコメントします (2 行使用)。編集された XML のフラグメントは、次のようになります。<!-- HTTP(S) Listener references Socket Binding (and indirectly - Interfaces) --> <!-- http-listener name="http" socket-binding="http" /> --> verify-client: org.xnio.SslClientAuthMode.NOT_REQUESTED, org.xnio.SslClientAuthMode.REQUESTED, org.xnio.SslClientAuthMode.REQUIRED <!--<https-listener name="https" socket-binding="https" security-realm="https" verify-client="NOT_REQUESTED" enabled="true" /> --> <https-listener name="https" socket-binding="https" worker="default" buffer-pool="default" enabled="true" receive-buffer="65536" send-buffer="65536" tcp-backlog="128" tcp-keep-alive="false" read-timeout="-1" write-timeout="-1" max-connections="1000000" resolve-peer-address="false" disallowed-methods="TRACE OPTIONS" secure="true" max-post-size="10485760" buffer-pipelined-data="false" max-header-size="1048576" max-parameters="1000" max-headers="200" max-cookies="200" allow-encoded-slash="false" decode-url="true" url-charset="UTF-8" always-set-keep-alive="true" max-buffered-request-size="16384" record-request-start-time="true" allow-equals-in-cookie-value="false" no-request-timeout="60000" request-parse-timeout="60000" rfc6265-cookie-validation="false" allow-unescaped-characters-in-url="false" certificate-forwarding="false" proxy-address-forwarding="false" enable-http2="false" http2-enable-push="false" http2-header-table-size="4096" http2-initial-window-size="65535" http2-max-concurrent-streams="-1" http2-max-frame-size="16384" http2-max-header-list-size="-1" require-host-http11="false" proxy-protocol="false" security-realm="https" verify-client="NOT_REQUESTED" enabled-cipher-suites="TLS_AES_256_GCM_SHA384" enabled-protocols="TLSv1.3" ssl-session-cache-size="0" ssl-session-timeout="0" />w:keystore要素を検索します。デフォルトでは、w:keystore要素は以下のように設定されます。<w:keystore path="${karaf.etc}/certs/server.keystore" provider="JKS" alias="server" keystore-password="secret" key-password="secret" generate-self-signed-certificate-host="localhost" />Undertow サーバーの証明書として
alice証明書をインストールするには、以下のようにw:keystore要素属性を変更します。-
pathを、ファイルシステムにおけるalice.ksファイルの場所 (絶対パス) に設定します。 -
providerをJKSに設定します。 -
aliasをキーストアのalice証明書エイリアスに設定します。 -
keystore-passwordを、キーストアをアンロックするパスワードの値に設定します。 -
key-passwordを、alice秘密鍵を暗号化するパスワードの値に設定します。 -
generate-self-signed-certificate-host属性設定を削除します。
-
たとえば、
alice.ksキーストアをインストールした後に、変更されたw:keystore要素は以下のようになります。<w:keystore path="${karaf.etc}/certs/alice.ks" provider="JKS" alias="alice" keystore-password="StorePass" key-password="KeyPass" />セキュアな HTTPS ポートがバインドする IP アドレスを指定するために使用される
<interface name="secure">タグを検索します。デフォルトでは、この要素は次のようにコメントアウトされます。<!--<interface name="secure">--> <!--<w:inet-address value="127.0.0.1" />--> <!--</interface>-->要素のコメントを解除し、
value属性をカスタマイズして、HTTPS ポートをバインドする IP アドレスを指定します。たとえば、ワイルドカード値0.0.0.0は、利用可能なすべての IP アドレスにバインドするように HTTPS を設定します。<interface name="secure"> <w:inet-address value="0.0.0.0" /> </interface><socket-binding name="https"タグを検索し、コメント解除します。このタグのコメントを解除すると、次のようになります。<socket-binding name="https" interface="secure" port="${org.osgi.service.http.port.secure}" />-
etc/undertow.xmlファイルを保存して閉じます。 - 設定の変更を有効にするために、Fuse コンテナーを再起動します。