以下のステップでは、ご使用環境のエンドポイント間の通信にセキュリティー層を使用可能にする方法について説明します。
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 トラストストアとして使用されます。
このステップでは、トランスポート・セキュリティーを使用可能にするように 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
使用するコマンドは Java SE セキュリティー・チュートリアル - ステップ 3 トピックのコマンドと同じです。
startOgServer.sh catalogServer -clusterSecurityFile ../security/security.xml
-serverProps ../security/server.properties -JMXServicePort 11001
-jvmArgs -Djava.security.auth.login.config="../security/og_jaas.config"
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 コンテナー・サーバーを実行します。
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"
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"
クライアント認証のために次のコマンドを実行します。
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.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
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
次のコマンドを実行してカタログ・サーバーを始動します。
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"
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 ファイルを元に戻します。