次の方法を使用して、Android で HTTP 投稿を作成しています。
public static Strign post(String url, List<BasicNameValuePair> postParams,
HttpClient client) throws ClientProtocolException, IOException {
if (client == null) {
client = getClient();
}
HttpPost httppost = new HttpPost(url);
if ((postParams == null)) {
postParams = new ArrayList<BasicNameValuePair>();
}
httppost.setEntity(new UrlEncodedFormEntity(postParams, "UTF-8"));
// Execute HTTP Post Request
HttpResponse response = client.execute(httppost);
return requestToString(response);
}
しかし、SSL 接続と自己署名証明書で使用すると、次の例外がスローされます。
Catch exception while startHandshake: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
return an invalid session with invalid cipher suite of SSL_NULL_WITH_NULL_NULL
javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:137)
at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:381)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:165)
at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:367)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:748)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:519)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:497)
これを解決して自己署名証明書を受け入れるにはどうすればよいですか?
ありがとう