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=true
SSL コネクターのテンプレート設定
# secure connector configuration org.osgi.service.http.secure.enabled = false #org.osgi.service.http.port.secure = 8443 #org.ops4j.pax.web.ssl.truststore = ${karaf.etc}/server.keystore #org.ops4j.pax.web.ssl.truststore.password = passw0rd #org.ops4j.pax.web.ssl.truststore.type = JKS #org.ops4j.pax.web.ssl.keystore = ${karaf.etc}/server.keystore #org.ops4j.pax.web.ssl.keystore.password = passw0rd #org.ops4j.pax.web.ssl.keystore.type = JKS #org.ops4j.pax.web.ssl.key.password = passw0rd #org.ops4j.pax.web.ssl.key.alias = server #org.ops4j.pax.web.ssl.clientauth.needed = false #org.ops4j.pax.web.ssl.protocol = TLSv1.3 #org.ops4j.pax.web.ssl.protocols.included = TLSv1.2 TLSv1.3 #org.ops4j.pax.web.ssl.ciphersuites.included = TLS_RSA_WITH_AES_128_CBC_SHA, TLS_RSA_WITH_AES_256_GCM_SHA384 #org.ops4j.pax.web.ssl.secureRandom.algorithm = NativePRNGNonBlocking #org.ops4j.pax.web.ssl.renegotiationAllowed = true #org.ops4j.pax.web.ssl.session.enabled = true
このプロパティーベースの設定は、etc/undertow.xml ファイルを使用したくないユーザー向けであり、Apache Karaf の一般的な用途向けです。ただし、Fuse Karaf の場合、推奨される方法は次のとおりです。
- etc/org.ops4j.pax.web.cfg で、org.osgi.service.http.secure.enabled = true、org.osgi.service.http.port.secure = 8443、および org.ops4j.pax.web.config.file = ${karaf.etc}/undertow.xml のみを設定します。
etc/undertow.xml で残りの要素 (証明書、パスワード、暗号など) を設定します。
etc/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" 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 コンテナーを再起動します。