自己署名証明書付きのホスティングを使用しています。そこで、ドメイン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デバイスを持っています。