前のトピック: HTTPS 対応の CA Configuration Automation サーバ の SDK サポート次のトピック: CA Configuration Automation サーバ UI のコンテキスト起動


X.509 証明書を使用したクライアント認証用の SDK サポート

このセクションでは、SDK を使用して、X.509 証明書によるクライアント認証を CA Configuration Automation がサポートするように設定する方法について説明します。 クライアント証明書を使用して CA Configuration Automation サーバの接続を確立するには、以下の SDK API メソッドを使用します。

import com.ca.acm.sdk.net.ACMSDKService; 
if (ACMSDKService.locateService(http://<yourserver>:<port>/services/SDKService) ) 
{ 
     if (ACMSDKService.beginSessionWithCertificate(certificateFileName, certificatePassphrase) ) 
     { 
          // do some work 
          ... 
     } 
     ACMSDKService.endsession(); 
}

注: このメソッドの詳細については、CA Configuration Automation サーバ インストール ディレクトリにある SDK javadoc を参照してください。

beginSessionWithCertificate() メソッドでは、コードはクライアント上で実行され、空のユーザ名およびパスワードを使用してサーバに対してコールを行う前にクライアント証明書が SSL コンテキストに設定されます。

SDK Web サービス コールを使用した接続の確立

クライアント証明書認証を使用して CA Configuration Automation サーバ 接続を確立するには、サーバに対してコールを行う前に以下のコードを実行します。

//This is java code (write equivalent code in your language (C, C++, .NET etc...) before making call to server.
String certificateFileName = “C:\\certs\\client.p12”
String certificatePassphrase = “password”
//create a trust manager that does not validate certificate chains
TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
     public java.security.cert.X509Certificate[] getAcceptedIssuers() {
          return null;
     }
     public void checkClientTrusted( 
          java.security.cert.X509Certificate[] certs, String authType) {
     }
     public void checkServerTrusted(
          java.security.cert.X509Certificate[] certs, String authType) {
     }
} };
char[] passphraseChar = certificatePassphrase.toCharArray();
try {
     KeyManagerFactory kmf = KeyManagerFactory.getInstance(“SunX509”);
     KeyStore ks = KeyStore.getInstance(“PKCS12”);
     ks.load(new FileInputStream(certificateFileName), passphraseChar);
     kmf.init(ks, passphraseChar);
     SSLContext sc = SSLContext.getInstance(“SSL”);
     sc.init(kmf.getKeyManagers(), trustAllCerts, new java.security.SecureRandom());
     SSLContext.setDefault(sc);
} catch (Exception e) {
   //handle exceptions here.
 }

GetSessionCredential Web サービス コールを使用し、入力として空のユーザ名およびパスワードを使用して接続を確立し、CA Configuration Automation サーバ とのセッションを作成します。 GetSessionCredential コールは、以降の CA Configuration Automation Web サービス コールで使用される認証情報の文字列を返します。