Java SE セキュリティー・チュートリアル - ステップ 6

以下のステップでは、ご使用環境のエンドポイント間の通信にセキュリティー層を使用可能にする方法について説明します。

始める前に

このタスクを続行する前に Java SE セキュリティー・チュートリアル - ステップ 5 を完了している必要があります。

このタスクについて

eXtreme Scale トポロジーは、ObjectGrid エンドポイント (クライアント、コンテナー・サーバー、およびカタログ・サーバー) 間のセキュア通信のために Transport Layer Security/Secure Sockets Layer (TLS/SSL) をサポートします。 このチュートリアル・ステップでは、それ以前のステップに基づいてトランスポート・セキュリティーを使用可能にします。

手順

  1. TLS/SSL 鍵および鍵ストアの作成
    トランスポート・セキュリティーを使用可能にするためには、鍵ストアとトラストストアを作成する必要があります。 この練習課題では、鍵ストアとトラストストアのペアのみを作成します。 これらのストアは ObjectGrid クライアント、コンテナー・サーバー、およびカタログ・サーバーのために使用されるもので、JDK 鍵ツールを使用して作成されます。
    • 鍵ストアに秘密鍵を作成します

      keytool -genkey -alias ogsample -keystore key.jks -storetype JKS -keyalg rsa -dname "CN=ogsample, OU=OGSample, O=acme, L=Your City, S=Your State, C=Your Country" -storepass ogpass -keypass ogpass -validity 3650

      このコマンドを使用すると、「ogsample」という鍵を含む鍵ストア key.jks が作成されます。 この鍵ストア key.jks は SSL 鍵ストアとして使用されます。

    • パブリック証明書をエクスポートします

      keytool -export -alias ogsample -keystore key.jks -file temp.key -storepass ogpass

      このコマンドを使用すると、「ogsample」という鍵の公開証明書が抽出されて、ファイル temp.key に格納されます。

    • クライアントのパブリック証明書をトラストストアにインポートします

      keytool -import -noprompt -alias ogsamplepublic -keystore trust.jks -file temp.key -storepass ogpass

      このコマンドを使用すると、公開証明書が鍵ストア trust.jks に追加されます。 この trust.jks は SSL トラストストアとして使用されます。

  2. ObjectGrid プロパティー・ファイルを構成します

    このステップでは、トランスポート・セキュリティーを使用可能にするように ObjectGrid プロパティー・ファイルを構成する必要があります。

    まず、key.jks ファイルと trust.jks ファイルを objectgridRoot/security ディレクトリーにコピーします。

    client.properties および server.properties ファイルで以下のプロパティーを設定します。

    transportType=SSL-Required
    
    alias=ogsample
    contextProvider=IBMJSSE2
    protocol=SSL
    keyStoreType=JKS
    keyStore=../security/key.jks
    keyStorePassword=ogpass
    trustStoreType=JKS
    trustStore=../security/trust.jks
    trustStorePassword=ogpass

    transportType: transportType の値は「SSL-Required」に設定されます。つまり、トランスポートに SSL が必要となります。 したがって、すべての ObjectGrid エンドポイント (クライアント、カタログ・サーバー、およびコンテナー・サーバー) で SSL 構成が設定され、すべてのトランスポート通信が暗号化されます。

    その他のプロパティーは SSL 構成を設定するために使用されます。 詳しくは、トランスポート層セキュリティーおよび Secure Sockets Layerを参照してください。必ずこのトピックの説明に従って、orb.properties ファイルを更新してください。

    必ずこのページに従って、orb.properties ファイルを更新してください。

    server.properties ファイルでは、 別のプロパティー clientAuthentication を追加し、それを false に設定する必要があります。 サーバー・サイドでは、クライアントを信頼する必要はありません。

    clientAuthentication=false

  3. アプリケーションの実行

    使用するコマンドは Java SE セキュリティー・チュートリアル - ステップ 3 トピックのコマンドと同じです。

    以下のコマンドを使用してカタログ・サーバーを始動します。
    1. bin ディレクトリーに移動します。cd objectgridRoot/bin
    2. カタログ・サーバーを始動します。
      • [Linux][Unix]
        startOgServer.sh catalogServer -clusterSecurityFile ../security/security.xml 
        -serverProps ../security/server.properties -JMXServicePort 11001 
        -jvmArgs -Djava.security.auth.login.config="../security/og_jaas.config"
      • [Windows]
        startOgServer.bat catalogServer -clusterSecurityFile ../security/security.xml 
        -serverProps ../security/server.properties -JMXServicePort 11001 -jvmArgs 
        -Djava.security.auth.login.config="../security/og_jaas.config"

      security.xml ファイルおよび server.properties ファイルは、 Java SE セキュリティー・チュートリアル - ステップ 2で作成されています。

      -JMXServicePort オプションを使用して、サーバーの JMX ポートを明示的に指定してください。 このオプションは、xscmd ユーティリティーを使用するために必要です。

      セキュア ObjectGrid コンテナー・サーバーを実行します。

    3. 再度、bin ディレクトリーに移動します。cd objectgridRoot/bin
      • [Linux][Unix]
        startOgServer.sh c0 -objectGridFile ../xml/SecureSimpleApp.xml 
        -deploymentPolicyFile ../xml/SimpleDP.xml -catalogServiceEndPoints 
        localhost:2809 -serverProps ../security/server.properties 
        -JMXServicePort 11002 -jvmArgs 
        -Djava.security.auth.login.config="../security/og_jaas.config" 
        -Djava.security.auth.policy="../security/og_auth.policy"
      • [Windows]
        startOgServer.bat c0 -objectGridFile ../xml/SecureSimpleApp.xml 
        -deploymentPolicyFile ../xml/SimpleDP.xml -catalogServiceEndPoints localhost:2809 
        -serverProps ../security/server.properties -JMXServicePort 11002 
        -jvmArgs -Djava.security.auth.login.config="../security/og_jaas.config" 
        -Djava.security.auth.policy="../security/og_auth.policy"
    前のコンテナー・サーバー始動コマンドとの以下の違いに注意してください。
    • SimpleApp.xml ファイルではなく、SecureSimpleApp.xml ファイルを使用します。
    • 別の -Djava.security.auth.policy を追加して、JAAS 許可ポリシー・ファイルをコンテナー・サーバー・プロセスに設定します。

    クライアント認証のために次のコマンドを実行します。

    1. cd objectgridRoot/bin
    2. javaHome/java -classpath ../lib/objectgrid.jar;../applib/sec_sample.jar 
      com.ibm.websphere.objectgrid.security.sample.guide.SecureSimpleApp 
      ../security/client.properties manager manager1

      ユーザー「manager」にはアカウンティング ObjectGrid のすべてのマップに対する許可が付与されているため、アプリケーションは正常に実行されます。

    xscmd ユーティリティーを使用して「accounting」グリッドのマップ・サイズを表示できます。
    • ディレクトリー objectgridRoot/bin に移動します。
    • xscmd コマンドを使用して、マップ・サイズを表示します。
      • [Unix][Linux]
        xscmd.sh -c showMapsizes -g accounting -m customer -prot SSL 
        -ts .¥security¥trust.jks -tsp ogpass -tst jks 
        -user manager -pwd manager1 -ks ..\security\key.jks -ksp ogpass -kst JKS 
        -cxpv IBMJSSE2 -tt SSL-Required
      • [Windows]
        xscmd.bat -c showMapsizes -g accounting -m customer -prot SSL 
        -ts ..¥security¥trust.jks -tsp ogpass -tst jks 
        -user manager -pwd manager1 -ks ..\security\key.jks -ksp ogpass -kst JKS 
        -cxpv IBMJSSE2 -tt SSL-Required

      ここで、-p 11001 を使用してカタログ・サービスの JMX ポートを指定することに注意してください。

      以下の出力が表示されます。

      This administrative utility is provided as a sample only and is not to 
      be considered a fully supported component of the WebSphere eXtreme Scale product.
      Connecting to Catalog service at localhost:1099
      *********** Displaying Results for Grid - accounting, MapSet - customer ***********
      *** Listing Maps for c0 ***
      Map Name: customer Partition #: 0 Map Size: 1 Shard Type: Primary
      Server Total: 1
      Total Domain Count: 1

    間違った鍵ストアを使用したアプリケーションの実行

    鍵ストア内の秘密鍵の公開証明書がトラストストアに含まれていないと、鍵がトラステッド鍵でありえないことを示す例外が発生します。

    このことを示すために、もう 1 つの鍵ストア key2.jks を作成します。

    keytool -genkey -alias ogsample -keystore key2.jks -storetype JKS -keyalg rsa -dname "CN=ogsample, OU=Your Organizational Unit, O=Your Organization, L=Your City, S=Your State, C=Your Country" -storepass ogpass -keypass ogpass -validity 3650

    次に、server.properties を変更して、 keyStore が、この新規の鍵ストア key2.jks をポイントするようにします。

    keyStore=../security/key2.jks

    次のコマンドを実行してカタログ・サーバーを始動します。

    1. bin ディレクトリーに移動します。cd objectgridRoot/bin
    2. カタログ・サーバーを始動します。
      [Linux][Unix]
      startOgServer.sh c0 -objectGridFile ../xml/SecureSimpleApp.xml 
      -deploymentPolicyFile ../xml/SimpleDP.xml -catalogServiceEndPoints localhost:2809 
      -serverProps ../security/server.properties -jvmArgs 
      -Djava.security.auth.login.config="../security/og_jaas.config" 
      -Djava.security.auth.policy="../security/og_auth.policy"
      [Windows]
      startOgServer.bat c0 -objectGridFile ../xml/SecureSimpleApp.xml 
      -deploymentPolicyFile ../xml/SimpleDP.xml -catalogServiceEndPoints localhost:2809
       -serverProps ../security/server.properties -jvmArgs 
      -Djava.security.auth.login.config="../security/og_jaas.config" 
      -Djava.security.auth.policy="../security/og_auth.policy"

      次の例外が表示されます。

      Caused by: com.ibm.websphere.objectgrid.ObjectGridRPCException:
          com.ibm.websphere.objectgrid.ObjectGridRuntimeException:
              SSL connection fails and plain socket cannot be used.

      最後に、key.jks ファイルを使用するように server.properties ファイルを元に戻します。