我正在尝试使用包含 HTTPS 的 URL 访问 Web 服务我收到没有对等证书错误。以下是我得到的错误。谁能帮帮我吗?
08-04 12:17:52.351: I/ApplicationPackageManager(8068): cscCountry is not German : INS
08-04 12:17:52.875: D/dalvikvm(8068): GC_EXTERNAL_ALLOC freed 60K, 48% free 2801K/5379K, external 504K/517K, paused 47ms
08-04 12:18:08.453: W/KeyCharacterMap(8068): Can't open keycharmap file
08-04 12:18:08.453: W/KeyCharacterMap(8068): Error loading keycharmap file '/system/usr/keychars/sec_keypad.kcm.bin'. hw.keyboards.0.devname='sec_keypad'
08-04 12:18:08.453: W/KeyCharacterMap(8068): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
08-04 12:18:17.656: D/dalvikvm(8068): GC_CONCURRENT freed 198K, 47% free 3005K/5639K, external 617K/1023K, paused 4ms+4ms
08-04 12:18:17.695: W/System.err(8068): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
08-04 12:18:17.718: W/System.err(8068): at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:258)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:381)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:164)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-04 12:18:17.718: W/System.err(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-04 12:18:17.718: W/System.err(8068): at com.osi.wolla.login.Login$task.doInBackground(Login.java:223)
08-04 12:18:17.718: W/System.err(8068): at com.osi.wolla.login.Login$task.doInBackground(Login.java:1)
08-04 12:18:17.718: W/System.err(8068): at android.os.AsyncTask$2.call(AsyncTask.java:185)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.FutureTask.run(FutureTask.java:138)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
08-04 12:18:17.718: W/System.err(8068): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
08-04 12:18:17.718: W/System.err(8068): at java.lang.Thread.run(Thread.java:1019)
08-04 12:18:17.718: I/System.out(8068): response....null
08-04 12:18:17.757: I/System.out(8068): url....https://mywolla.com/mobwebservices/smails_rest.php
08-04 12:18:21.687: W/webserviceCall(8068): Error for URL https://mywolla.com/mobwebservices/smails_rest.php
08-04 12:18:21.687: W/webserviceCall(8068): javax.net.ssl.SSLPeerUnverifiedException: No peer certificate
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.harmony.xnet.provider.jsse.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:258)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.conn.ssl.AbstractVerifier.verify(AbstractVerifier.java:93)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:381)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:164)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:359)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
08-04 12:18:21.687: W/webserviceCall(8068): at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
08-04 12:18:21.687: W/webserviceCall(8068): at com.osi.wolla.webserviceCall.getBundle(webserviceCall.java:870)
08-04 12:18:21.687: W/webserviceCall(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:165)
08-04 12:18:21.687: W/webserviceCall(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:1)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.AsyncTask.finish(AsyncTask.java:417)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.AsyncTask.access$300(AsyncTask.java:127)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 12:18:21.687: W/webserviceCall(8068): at android.os.Looper.loop(Looper.java:130)
08-04 12:18:21.687: W/webserviceCall(8068): at android.app.ActivityThread.main(ActivityThread.java:3687)
08-04 12:18:21.687: W/webserviceCall(8068): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 12:18:21.687: W/webserviceCall(8068): at java.lang.reflect.Method.invoke(Method.java:507)
08-04 12:18:21.687: W/webserviceCall(8068): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
08-04 12:18:21.687: W/webserviceCall(8068): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
08-04 12:18:21.687: W/webserviceCall(8068): at dalvik.system.NativeStart.main(Native Method)
08-04 12:18:21.695: D/AndroidRuntime(8068): Shutting down VM
08-04 12:18:21.695: W/dalvikvm(8068): threadid=1: thread exiting with uncaught exception (group=0x40018578)
08-04 12:18:21.695: E/AndroidRuntime(8068): FATAL EXCEPTION: main
08-04 12:18:21.695: E/AndroidRuntime(8068): java.lang.NullPointerException
08-04 12:18:21.695: E/AndroidRuntime(8068): at java.io.StringReader.<init>(StringReader.java:46)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.osi.wolla.xmlParser.parseUser(xmlParser.java:239)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:168)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.osi.wolla.login.Login$task.onPostExecute(Login.java:1)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.AsyncTask.finish(AsyncTask.java:417)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.AsyncTask.access$300(AsyncTask.java:127)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.os.Looper.loop(Looper.java:130)
08-04 12:18:21.695: E/AndroidRuntime(8068): at android.app.ActivityThread.main(ActivityThread.java:3687)
08-04 12:18:21.695: E/AndroidRuntime(8068): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 12:18:21.695: E/AndroidRuntime(8068): at java.lang.reflect.Method.invoke(Method.java:507)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
08-04 12:18:21.695: E/AndroidRuntime(8068): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
08-04 12:18:21.695: E/AndroidRuntime(8068): at dalvik.system.NativeStart.main(Native Method)
这是我的代码。
final String URL = "https://mywolla.com/mobwebservices/svalidateuser.php?wsdl";
String response = null;
try {
HostnameVerifier hostnameVerifier = org.apache.http.conn.ssl.SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER;
DefaultHttpClient client = new DefaultHttpClient();
SchemeRegistry registry = new SchemeRegistry();
SSLSocketFactory socketFactory = SSLSocketFactory.getSocketFactory();
socketFactory.setHostnameVerifier((X509HostnameVerifier) hostnameVerifier);
registry.register(new Scheme("http", PlainSocketFactory.getSocketFactory(), 80));
registry.register(new Scheme("https", socketFactory, 443));
SingleClientConnManager mgr = new SingleClientConnManager(client.getParams(), registry);
DefaultHttpClient httpClient = new DefaultHttpClient(mgr, client.getParams());
// Set verifier
HttpsURLConnection.setDefaultHostnameVerifier(hostnameVerifier);
// Example send http request
HttpPost httpPost = new HttpPost(URL);
HttpResponse response1 = httpClient.execute(httpPost);