SSL 用のカスタム鍵マネージャーの作成

任意の管理有効範囲でカスタム鍵マネージャー構成を作成して、 新規鍵マネージャーを Secure Sockets Layer (SSL) 構成と関連付けることができます。

始める前に

カスタム鍵マネージャーの Java™ アーカイブ (.JAR) ファイルを WebSphere® Application Server の was.install.root/lib/ext ディレクトリーに 作成、パッケージ、および配置する必要があります。

このタスクについて

管理コンソールで以下のステップを実行します。

手順

  1. カスタム鍵マネージャーをセル有効範囲で作成するか、 または例えば、ノード、サーバー、クラスターなど、セル有効範囲より下で作成するかを決定します。
    重要: セル有効範囲より下のレベルでカスタム鍵マネージャーを作成する場合、 同一またはそれ以上の有効範囲の Secure Sockets Layer (SSL) 構成とのみ関連付けることができます。鍵マネージャーより下の有効範囲の SSL 構成では、 鍵マネージャー構成は表示されません。
    • カスタム鍵マネージャーをセル有効範囲で作成するには、 「セキュリティー」>「SSL 証明書および鍵管理」>「鍵マネージャー」をクリックします。セルのすべての SSL 構成では、 セル有効範囲で鍵マネージャーを選択できます。
    • セル・レベルよりも下の有効範囲でカスタム鍵マネージャーを作成する場合は、「セキュリティー」>「SSL 証明書および鍵管理」>「エンドポイント・セキュリティー構成の管理」>「{Inbound | Outbound}」>「SSL_configuration」>「鍵マネージャー」をクリックします。
  2. 新規」をクリックして、新規鍵マネージャーを作成します。
  3. 固有の鍵マネージャー名を入力します。
  4. カスタム」実装設定を選択します。 カスタム設定では、Java インターフェース javax.net.ssl.X509KeyManager 、および必要に応じて com.ibm.wsspi.ssl.KeyManagerExtendedInfo WebSphere Application Server インターフェースの実装を持つ Java クラスを定義できます。 標準実装設定は、 鍵マネージャーがプロバイダーおよびアルゴリズムとして Java セキュリティー・プロバイダー・リストで定義済みの場合 (カスタム鍵マネージャーではない場合) にのみ適用されます。 通常、標準鍵マネージャーの場合、 アルゴリズム = IbmX509、プロバイダー = IBMJSSE2 です。
  5. クラス名を入力します。例えば、com.ibm.test.CustomKeyManager などです。
  6. 以下のいずれか 1 つのアクションを選択します。
    • 適用」をクリックし、「追加プロパティー」の下にある「カスタム・プロパティー」をクリックして、 新規カスタム鍵マネージャーにカスタム・プロパティーを追加します。カスタム・プロパティーの追加が終了したあと、 「OK」および「保存」をクリックして、次のステップへ進みます。
    • OK」および「保存」をクリックして、次のステップへ進みます。
  7. ページ・ナビゲーションの「SSL 証明書および鍵管理」をクリックします。
  8. 以下のいずれか 1 つのアクションを選択します。
    • セル有効範囲の SSL 構成用に、「関連項目」の下にある「SSL 構成」をクリックします。
    • エンドポイント・セキュリティー構成の管理」をクリックして、より下の有効範囲で SSL 構成を選択します。
  9. 新規カスタム鍵マネージャーと関連付ける既存の SSL 構成のリンクをクリックします。 カスタム鍵マネージャーを既存の構成と関連付ける代わりに、 新規 SSL 構成を作成できます。詳しくは、以下の例を参照してください。
  10. 「追加プロパティー」の下にある「トラストおよび鍵マネージャー」をクリックします。
  11. 鍵マネージャー」ドロップダウン・リストで、 新規カスタム鍵マネージャーを選択します。 新規カスタム鍵マネージャーがリストにない場合、 ステップ 8 での選択と同じレベルまたはより下の有効範囲の SSL 構成有効範囲を選択しているかどうかを確認します。
  12. OK」をクリックしてから「保存」をクリックします。

タスクの結果

WebSphere Application Server のインストール・ディレクトリーの JAR ファイルを参照して、 接続ハンドシェーク中にカスタム構成を SSL 構成と関連付けるカスタム鍵マネージャー構成が作成されました。

カスタム Secure Sockets Layer 鍵選択用のカスタム鍵マネージャーの作成。 以下の例は、サンプルのカスタム鍵マネージャーです。 この単純な鍵マネージャーは、 別名プロパティー com.ibm.ssl.keyStoreClientAlias または com.ibm.ssl.keyStoreServerAlias を使用して設定されている場合、 構成された別名を戻します。 これは、鍵マネージャーが 接続のいずれの側で使用されているかによって異なります。 これらのプロパティーが未設定の場合、 鍵マネージャーは、JSSE のデフォルト IbmX509 鍵マネージャーに従って、 別名を選択します。

カスタム鍵マネージャーをビルドしてパッケージした後、ピュア・クライアント用の ssl.client.props ファイルを使用するか、管理コンソールの SSLConfiguration KeyManager リンクを使用してこのマネージャーを構成できます。 鍵マネージャーについての詳細は、X.509 証明書 ID の鍵マネージャー制御を参照してください。

所定の Secure Sockets Layer (SSL) 構成に対しては、一度に 1 つの鍵マネージャーしか構成できないため、サーバー・サイドの証明書選択は、デフォルトの IbmX509 鍵マネージャーを指定した場合と同じようには動作しない可能性があります。 カスタム鍵マネージャーが構成されている場合、chooseClientAlias または chooseServerAlias が呼び出されたときに、提供された SSL 構成からの別名の選択が正しく設定されているかどうかの確認は、この鍵マネージャーのオーナーによって異なります。 com.ibm.ssl.keyStoreClientAlias および com.ibm.ssl.keyStoreServerAlias SSL プロパティーを探してください。
注: この例はサンプルとしてのみ使用します。サポートはされていません。
package com.ibm.test;

import java.security.cert.X509Certificate;
import com.ibm.wsspi.ssl.KeyManagerExtendedInfo;

public final class CustomKeyManager 
		implements javax.net.ssl.X509KeyManager, com.ibm.wsspi.ssl.KeyManagerExtendedInfo
{
    private java.util.Properties props = null;
    private java.security.KeyStore ks = null;
    private javax.net.ssl.X509KeyManager km = null;
    private java.util.Properties sslConfig = null;
    private String clientAlias = null;
    private String serverAlias = null;
    private int clientslotnum = 0;
    private int serverslotnum = 0;

    public CustomKeyManager()
    {
    }

    /**
     * Method called by WebSphere Application Server runtime to set the custom
     * properties.
     * 
      * @param java.util.Properties - custom props
     */
    public void setCustomProperties(java.util.Properties customProps)
    {
        props = customProps;
    }

    private java.util.Properties getCustomProperties()
    {
        return props;
    }

    /**
      * Method called by WebSphere Application Server runtime to set the SSL
      * configuration properties being used for this connection.
     * 
      * @param java.util.Properties - contains a property for the SSL configuration.
     */
    public void setSSLConfig(java.util.Properties config)
    {
        sslConfig = config;                                   
    }

    private java.util.Properties getSSLConfig()
    {
        return sslConfig;
    }

    /**
      * Method called by WebSphere Application Server runtime to set the default
      * X509KeyManager created by the IbmX509 KeyManagerFactory using the KeyStore
      * information present in this SSL configuration.  This allows some delegation
      * to the default IbmX509 KeyManager to occur.
     * 
      * @param javax.net.ssl.KeyManager defaultX509KeyManager - default key manager for IbmX509
     */
    public void setDefaultX509KeyManager(javax.net.ssl.X509KeyManager defaultX509KeyManager)
    {
        km = defaultX509KeyManager;
    }

    public javax.net.ssl.X509KeyManager getDefaultX509KeyManager()
    {
        return km;
    }

    /**
      * Method called by WebSphere Application Server runtime to set the SSL
      * KeyStore used for this connection.
     * 
      * @param java.security.KeyStore - the KeyStore currently configured
     */
    public void setKeyStore(java.security.KeyStore keyStore)
    {
        ks = keyStore;
    }

    public java.security.KeyStore getKeyStore()
    {
        return ks;
    }

 /**
      * Method called by custom code to set the server alias.
     * 
      * @param String - the server alias to use
     */
    public void setKeyStoreServerAlias(String alias)
    {
        serverAlias = alias;
    }

    private String getKeyStoreServerAlias()
    {
        return serverAlias;
    }

    /**
      * Method called by custom code to set the client alias.
     * 
      * @param String - the client alias to use
     */
    public void setKeyStoreClientAlias(String alias)
    {
        clientAlias = alias;
    }
    
    private String getKeyStoreClientAlias()
    {
        return clientAlias;
    }

    /**
      * Method called by custom code to set the client alias and slot (if necessary).
     * 
      * @param String - the client alias to use
      * @param int - the slot to use (for hardware)
     */
    public void setClientAlias(String alias, int slotnum) throws Exception
    {
        if ( !ks.containsAlias(alias))
        {
            throw new IllegalArgumentException ( "Client alias " + alias + " 
            not found in keystore." );
        }
        this.clientAlias = alias;
        this.clientslotnum = slotnum;
    }

    /**
      * Method called by custom code to set the server alias and slot (if necessary).
     * 
      * @param String - the server alias to use
      * @param int - the slot to use (for hardware)
     */
    public void setServerAlias(String alias, int slotnum) throws Exception
    {
        if ( ! ks.containsAlias(alias))
        {
            throw new IllegalArgumentException ( "Server alias " + alias + " 
            not found in keystore." );
        }
        this.serverAlias = alias;
        this.serverslotnum = slotnum;
    }


    /**
      * Method called by JSSE runtime to when an alias is needed for a client
      * connection where a client certificate is required.
     * 
     * @param String keyType
     * @param Principal[] issuers
      * @param java.net.Socket socket (not always present)
     */
    public String chooseClientAlias(String[] keyType, java.security.Principal[]
    issuers, java.net.Socket socket)
    {
        if (clientAlias != null && !clientAlias.equals(""))
        {
            String[] list = km.getClientAliases(keyType[0], issuers);
            String aliases = "";

            if (list != null)
            {
                boolean found=false;
                			for (int i=0; i<list.length; i++)
                {
                    aliases += list[i] + " ";
                    if (clientAlias.equalsIgnoreCase(list[i]))
                        found=true;
                }

                if (found)
                {
                    return clientAlias;
                }

            }
        }
        
         // client alias not found, let the default key manager choose.
        String[] keyArray = new String [] {keyType[0]};
        String alias = km.chooseClientAlias(keyArray, issuers, null);
        return alias.toLowerCase();
    }

    /**
      * Method called by JSSE runtime to when an alias is needed for a server
      * connection to provide the server identity.
     * 
     * @param String[] keyType
     * @param Principal[] issuers
      * @param java.net.Socket socket (not always present)
     */
    public String chooseServerAlias(String keyType, java.security.Principal[]
    issuers, java.net.Socket socket)
    {
        if (serverAlias != null && !serverAlias.equals(""))
        {
             // get the list of aliases in the keystore from the default key manager
            String[] list = km.getServerAliases(keyType, issuers);
            String aliases = "";

            if (list != null)
            {
                boolean found=false;
                			for (int i=0; i<list.length; i++)
                {
                    aliases += list[i] + " ";
                    if (serverAlias.equalsIgnoreCase(list[i]))
                        found = true;
                }

                if (found)
                {
                    return serverAlias;
                }
            }
        }

         // specified alias not found, let the default key manager choose.
        String alias = km.chooseServerAlias(keyType, issuers, null);
        return alias.toLowerCase();
    }

    public String[] getClientAliases(String keyType, java.security.Principal[] issuers)
    {
        return km.getClientAliases(keyType, issuers);
    }

    public String[] getServerAliases(String keyType, java.security.Principal[] issuers)
    {
        return km.getServerAliases(keyType, issuers);
    }

    public java.security.PrivateKey getPrivateKey(String s)
    {
        return km.getPrivateKey(s);
    }

    public java.security.cert.X509Certificate[] getCertificateChain(String s)
    {
        return km.getCertificateChain(s);
    }

    public javax.net.ssl.X509KeyManager getX509KeyManager()
    {
        return km;
    }

}

次のタスク

純粋なクライアントに対して、カスタム鍵マネージャーを作成できます。詳しくは、『AdminTask オブジェクトの keyManagerCommands コマンド・グループ』を参照してください。

トピックのタイプを示すアイコン タスク・トピック



タイム・スタンプ・アイコン 最終更新: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=tsec_sslcreatecuskeymgr
ファイル名:tsec_sslcreatecuskeymgr.html