1

自己署名証明書付きのホスティングを使用しています。そこで、ドメインhttps://www.marpel.cz/から証明書をダウンロードし、 http: //portecle.sourceforge.net/を使用して.bksファイルを作成しました。

https接続を確立し、Webサービスからデータを取得する必要があります。ksoap2ライブラリを使用しています。ksoap2wikiに記載されているクラスConnectionWithSelfSignedCertificateをコピーして使用しました。

これが私がkeyStoreを作成する方法です

    MainActivity.java
    // Get an instance of the Bouncy Castle KeyStore format
    try {
        this.keyStore = KeyStore.getInstance("BKS");
    } catch (KeyStoreException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }
    // Get the raw resource, which contains the keystore with
    // your trusted certificates (root and any intermediate certs)
    InputStream in = this.getApplicationContext().getResources().openRawResource(R.raw.myCer);
    try {
        // Initialize the keystore with the provided trusted certificates
        // Also provide the password of the keystore
        this.keyStore.load(in, "myPass".toCharArray());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }finally {
        try {
            in.close();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    try {
        this.sslSocketFactory = new ConnectionWithSelfSignedCertificate(this.keyStore).getSSLSocketFactory();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

そしてこれはAsyncTaskからのコードです

background task
final HttpsTransportSE transportSE = new HttpsTransportSE(URL, PORT, SERVICE, TIMEOUT);

    try {
        ((HttpsServiceConnectionSE) transportSE.getServiceConnection()).setSSLSocketFactory(this.sslSocketFactory);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

transportSE.call(SOAP_ACTION、envelope);を呼び出すと IOExceptionが発生し、ホスト名'www.marpel.cz'が検証されませんでした。私は何を間違えますか?

ICS4.1.2デバイスを持っています。

4

2 に答える 2

0

まず、自己署名証明書を使用していますか?

はいの場合は、次のリンクに従ってください: android-webservices-via-ksoap2-https

https 接続を作成し、証明書を受け入れるには、追加のクラスが必要です。すべての準備が整ったら、transportSE.

于 2013-02-22T14:19:55.277 に答える
0

私の最初の投稿のコードは正常に動作します。自己署名証明書が別のドメインに対して発行されていることがわかりました。証明書を修正したところ、すべて正常に動作しました。

固定証明書はここで実行されます https://www.marpel.cz:445/

ありがとう、マーティン。

于 2013-02-22T15:14:33.353 に答える