2

Androidで実行されている証明書を取得する際に大きな問題があります。WCF サービスに接続する Android クライアントがあります。

問題は、証明書が転送されていないことだと思います。エラー メッセージが表示されます: 403 禁止されています (応答で)。あなたが私を助けてくれることを本当に願っています。=>私のAndroidクライアントで

Internet Explorer では問題なく動作します => status 200

この記事を見つけました: http://android-developers.blogspot.de/2012/03/unifying-key-store-access-in-ics.html

「秘密鍵の一般的な用途は、SSL クライアント認証です。これは、KeyChain API から取得した PrivateKey を返すカスタム X509KeyManager で HttpsURLConnection を使用することによって実装できます。ICS 用のオープン ソースの電子メール アプリケーションは、X509ExtendedKeyManager で KeyChain を使用します。詳細については、ソース コード (SSLUtils.java 内) を参照してください。"

SSLUtils クラスをチェックアウトし、使用しようとしています。

ここにいくつかのコードがあります:

private void setHttpsAdvanced() {
    HostAuth ht = new HostAuth();
    ht.mPort = 443;
    ht.mClientCertAlias = "jensZert";

    HttpParams params = getHttpParams();
    MyThreadSafeClientConnManager ccm = MyThreadSafeClientConnManager
            .newInstance(params, true, 443);

    try {
        MyThreadSafeClientConnManager.makeScheme(true, false,    
                          ht.mClientCertAlias);

        ccm.registerClientCert(getApplicationContext(), ht);
        // checkCertificate(ht.mClientCertAlias);

    } catch (CertificateException e) {
        Log.d(TAG, e.getMessage());
        e.printStackTrace();
    }

    this.httpclient = new DefaultHttpClient(ccm, params);

    connectionInfo = this.getConnectionInfo();

    this.url = String.format("%1$s://%2$s/%3$s/%4$s",
            connectionInfo.Protocol, connectionInfo.ServerName,
            connectionInfo.WebserviceName, connectionInfo.Path);

    httpGet = new HttpGet(url);
}


private String callTheWebserviceCertificate() {
    this.setupClient();
    String result = "";

    HttpResponse response = null;
    try {
        response = (HttpResponse) this.httpclient.execute(httpGet);
        result = EntityUtils.toString(response.getEntity());

    } catch (ClientProtocolException e) {

        e.printStackTrace();
    } catch (IOException e) {

        result = e.getMessage() + "\n";

        for (StackTraceElement el : e.getStackTrace()) {
            result += el.toString() + "\n";
        }

        Log.d(TAG, result);
    }
    return result;
}

こんにちは、ジェンス

4

0 に答える 0