WebLogicセキュリティ・サービスは、X509証明書チェーンを検索および検証するためのCertificate Lookup and Validation (CLV) APIを提供します。
証明書パスは、メモリー内に証明書チェーンを格納するJDKクラスです。「証明書パス」という用語は、証明書チェーンを検索および検証するためのJDKアーキテクチャおよびフレームワークを指す場合にも使われます。このCLVフレームワークは、JDK CertPath機能を拡張および完了します。証明書パス・プロバイダは、WebLogicインタフェースとJDKインタフェースの緊密な統合に依存します。
アプリケーション・コードでの証明書チェーンの作成および検証には、WebLogic Serverに用意されたデフォルトの証明書パス・プロバイダか、カスタム証明書パス・プロバイダを使用できます。
この章の内容は次のとおりです。
アプリケーションで証明書パス・ビルダーを使用するには、次の手順に従います。
CertPathSelectorインタフェース(weblogic.security.pk.CertPathSelector)には、証明書パスを検索して検証するための選択条件が含まれています。証明書パスは様々な方法で検索できるため、選択条件ごとに派生クラスが実装されています。
各セレクタ・クラスには、選択データおよびコンストラクタを取得するためのメソッドが1つまたは複数あります。
CertPathSelectorインタフェースを実装するweblogic.security.pk内のクラスは、次に示すように、サポートされている証明書チェーン検索の種類ごとに1つずつあります。
EndCertificateSelector - 目的の証明書がある証明書チェーンを検索および検証する場合に使用します。
IssuerDNSerialNumberSelector - 目的の証明書の発行DNとシリアル番号から証明書チェーンを検索および検証する場合に使用します。
SubjectDNSelector - 目的の証明書のサブジェクトDNから証明書チェーンを検索および検証する場合に使用します。
SubjectKeyIdentifierSelector - 目的の証明書のサブジェクト・キー識別子(X509証明書の省略可能なフィールド)から証明書チェーンを検索および検証する場合に使用します。
注意:
サポートされるセレクタは、構成済みの証明書パス・プロバイダによって異なります。構成済みの証明書パス・プロバイダは管理者が決定します。
WebLogic証明書パス・プロバイダでは、EndCertificateSelectorセレクタのみを使用します。
例10-1に、セレクタの選択例を示します。
例10-1 証明書チェーン・セレクタの指定
// you already have the end certificate // and want to use it to lookup and // validate the corresponding chain X509Certificate endCertificate = ... // make a cert chain selector CertPathSelector selector = new EndCertificateSelector(endCertificate);
JDKのCertPathBuilder.build()メソッドに、CertPathBuilderParametersのインスタンスをCertPathParametersオブジェクトとして渡します。
次のコンストラクタとメソッドを利用できます。
CertPathBuilderParameters
public CertPathBuilderParameters(String realmName,
CertPathSelector selector,
X509Certificate[]
trustedCAs,
ContextHandler context)
CertPathBuilderParametersを作成します。
レルム名を指定する必要があります。そのためには、ドメインのSecurityConfigurationMBeanを取得します。次に、SecurityConfigurationMBeanのデフォルトのレルム属性(レルムMBean)を取得します。最後に、レルムMBeanの名前属性を取得します。レルム名の取得には、実行時JMX MBeanサーバーを使用する必要があります。
selectorを指定する必要があります。weblogic.security.pk.CertPathSelectorインタフェースのいずれかの派生クラスを使用します。証明書パスを検索および検証するための選択条件の指定については、「CertPathSelectorのインスタンス化」を参照してください。
信頼性のあるCAがある場合は指定します。そうしない場合は、サーバーの信頼性のあるCAが使用されます。これらは、構成済みの証明書パス・ビルダーおよび証明書パス検証プロバイダに対する単なるヒントです。それらは、使用する検索/検証アルゴリズムによって、信頼性のあるCAを使用する場合と使用しない場合があります。
ContextHandlerは、構成済みの証明書パス・ビルダーおよび証明書パス検証プロバイダが、チェーンの検索と検証に使用する名前/値ペアのリスト(オプション)を渡すために使用します。他の種類のセキュリティ・プロバイダに渡されるコンテキスト・ハンドラと対称的です。コンテキスト・パラメータがないことを示すためには、コンテキストをnullに設定します。
clone
Object clone()
このインタフェースのクローンは作成できません。
例10-2に、CertPathBuilderParametersのインスタンスを渡す例を示します。
例10-2 CertPathBuilderParametersのインスタンスを渡す例
// make a cert chain selector CertPathSelector selector = new EndCertificateSelector(endCertificate); String realm = _; // create and populate a context handler if desired, or null ContextHandler context = _; // pass in a list of trusted CAs if desired, or null X509Certificate[] trustedCAs = _; // make the params CertPathBuilderParams params = new CertPathBuilderParameters(realm, selector, context, trustedCAs);
java.security.cert.CertPathBuilderインタフェースは、CertPathBuilderクラスのAPIです。JDKのCertPathBuilderインタフェースを使用するには、次を行います:
例10-3 証明書チェーンの検索
import weblogic.security.pk.CertPathBuilderParameters;
import weblogic.security.pk.CertPathSelector;
import weblogic.security.pk.EndCertificateSelector;
import weblogic.security.service.ContextHandler;
import java.security.cert.CertPath;
import java.security.cert.CertPathBuilder;
import java.security.cert.X509Certificate;
// you already have the end certificate
// and want to use it to lookup and
// validate the corresponding chain
X509Certificate endCertificate = ...
// make a cert chain selector
CertPathSelector selector = new EndCertificateSelector(endCertificate);
String realm = _;
// create and populate a context handler if desired
ContextHandler context = _;
// pass in a list of trusted CAs if desired
X509Certificate[] trustedCAs = _;
// make the params
CertPathBuilderParams params =
new CertPathBuilderParameters(realm, selector, context, trustedCAs);
// get the WLS CertPathBuilder
CertPathBuilder builder =
CertPathBuilder.getInstance("WLSCertPathBuilder");
// use it to look up and validate the chain
CertPath certpath = builder.build(params).getCertPath();
X509Certificate[] chain =
certpath.getCertificates().toArray(new X509Certificate[0]);
アプリケーションで証明書パス検証プロバイダを使用するには、次の手順に従います。
JDKのCertPathValidator.validate()メソッドに、CertPathValidatorParametersのインスタンスをCertPathParametersオブジェクトとして渡します。
次のコンストラクタとメソッドを利用できます。
CertPathValidatorParameters
public CertPathValidatorParameters(String realmName,
X509Certificate[] trustedCAs,
ContextHandler context)
CertPathValidatorParametersを作成します。
レルム名を指定する必要があります。そのためには、ドメインのSecurityConfigurationMBeanを取得します。次に、SecurityConfigurationMBeanのデフォルトのレルム属性(レルムMBean)を取得します。最後に、レルムMBeanの名前属性を取得します。レルム名の取得には、実行時JMX MBeanサーバーを使用する必要があります。
信頼性のあるCAがある場合は指定します。そうしない場合は、サーバーの信頼性のあるCAが使用されます。これらは、構成済みの証明書パス・ビルダーおよび証明書パス検証プロバイダに対する単なるヒントです。それらは、使用する検索/検証アルゴリズムによって、信頼性のあるCAを使用する場合と使用しない場合があります。
ContextHandlerは、構成済みの証明書パス・ビルダーおよび証明書パス検証プロバイダが、チェーンの検索と検証に使用する名前/値ペアのリスト(オプション)を渡すために使用します。他の種類のセキュリティ・プロバイダに渡されるコンテキスト・ハンドラと対称的です。コンテキスト・パラメータがないことを示すためには、コンテキストをnullに設定します。
clone
Object clone()
このインタフェースのクローンは作成できません。
例10-4に、CertPathValidatorParametersのインスタンスを渡す例を示します。
例10-4 CertPathValidatorParametersのインスタンスを渡す例
// get the WLS CertPathValidator
CertPathValidator validator =
CertPathValidator.getInstance("WLSCertPathValidator");
String realm = _;
// create and populate a context handler if desired, or null
ContextHandler context = _;
// pass in a list of trusted CAs if desired, or null
X509Certificate[] trustedCAs = _;
// make the params (for the default security realm)
CertPathValidatorParams params =
new CertPathValidatorParams(realm, context, trustedCAs);
java.security.cert.CertPathValidatorインタフェースは、CertPathValidatorクラスのAPIです。JDKのCertPathValidatorインタフェースを使用するには、次を行います:
例10-5 追加の検証の実行
import weblogic.security.pk.CertPathValidatorParams;
import weblogic.security.service.ContextHandler;
import java.security.cert.CertPath;
import java.security.cert.CertPathValidator;
import java.security.cert.X509Certificate;
// you already have an unvalidated X509 certificate chain
// and you want to get it validated
X509Certificate[] chain = ...
// convert the chain to a CertPath
CertPathFactory factory = CertPathFactory.getInstance("X509");
ArrayList list = new ArrayList(chain.length);
for (int i = 0; i < chain.length; i++) {
list.add(chain[i]);
}
CertPath certPath = factory.generateCertPath(list);
// get the WLS CertPathValidator
CertPathValidator validator =
CertPathValidator.getInstance("WLSCertPathValidator");
String realm = _;
// create and populate a context handler if desired, or null
ContextHandler context = _;
// pass in a list of trusted CAs if desired, or null
X509Certificate[] trustedCAs = _;
// make the params (for the default security realm)
CertPathValidatorParams params =
new CertPathValidatorParams(realm, context, trustedCAs);
// use it to validate the chain
validator.validate(certPath, params);