尝试到达应用引擎端点时出现 SSLHandshakeException

SSLHandshakeException when trying to reach app engine endpoint

我正在尝试从 android 客户端连接到我的端点方法之一到我的本地 运行 应用引擎后端。问题是我遇到了 SSLHandshakeException。我的 API 不受 OAuth 保护。我尝试达到的方法如下所示:

@ApiMethod(name = "register")
public UserInfo registerUser(UserInfo userInfo) {
    try {
        checkUserParameters(userInfo);
        ofy().save().entity(userInfo).now();
        return ofy().load().entity(userInfo).now();
    } catch (InvalidPropertiesFormatException e) {
        logger.info(e.getMessage());
        return null;
    }
}

从我的客户那里我这样做:

  if (regService == null) {
            UserInfoApi.Builder builder = new UserInfoApi.Builder(AndroidHttp.newCompatibleTransport(),
                   new AndroidJsonFactory(), null)
                .setRootUrl(LoginActivity.LOCALHOST_IP)
                .setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
                    @Override
                    public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest)
                            throws IOException {
                        abstractGoogleClientRequest.setDisableGZipContent(true);
                    }
           });

           regService = builder.build();
           UserInfo userInfo = new UserInfo();
           userInfo.setGcmId(registerToGcm());
           userInfo.setAccountName(params[0]);
           userInfo.setEmail(params[0]);
           userInfo.setProfilePictureUrl(null);
           UserInfo userInfo = regService.register(userInfo).execute();
  }

出于某种原因,这不起作用,我也尝试过将后端模块导入 android studio 时得到的 API,但它给出了相同的错误。

日志:

03-18 12:21:21.642  30454-30477/huka.com.repli W/System.err﹕ javax.net.ssl.SSLHandshakeException: Handshake failed
03-18 12:21:21.642  30454-30477/huka.com.repli W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:374)
03-18 12:21:21.642  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.Connection.upgradeToTls(Connection.java:197)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.Connection.connect(Connection.java:151)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:276)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:211)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:373)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.HttpURLConnectionImpl.connect(HttpURLConnectionImpl.java:106)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.HttpURLConnectionImpl.getOutputStream(HttpURLConnectionImpl.java:208)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.DelegatingHttpsURLConnection.getOutputStream(DelegatingHttpsURLConnection.java:218)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.android.okhttp.internal.http.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:25)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:77)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:965)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at gcm.GcmRegistrationAsyncTask.registerToService(GcmRegistrationAsyncTask.java:80)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at gcm.GcmRegistrationAsyncTask.doInBackground(GcmRegistrationAsyncTask.java:69)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at gcm.GcmRegistrationAsyncTask.doInBackground(GcmRegistrationAsyncTask.java:26)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at android.os.AsyncTask.call(AsyncTask.java:288)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at java.util.concurrent.FutureTask.run(FutureTask.java:237)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at android.os.AsyncTask$SerialExecutor.run(AsyncTask.java:231)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ at java.lang.Thread.run(Thread.java:818)
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0xaf724200: Failure in SSL library, usually a protocol error
03-18 12:21:21.643  30454-30477/huka.com.repli W/System.err﹕ error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol (external/openssl/ssl/s23_clnt.c:790 0xac490e61:0x00000000)
03-18 12:21:21.644  30454-30477/huka.com.repli W/System.err﹕ at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method)
03-18 12:21:21.644  30454-30477/huka.com.repli W/System.err﹕ at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:302)
03-18 12:21:21.644  30454-30477/huka.com.repli W/System.err﹕ ... 23 more

所以...问题是我在客户端上设置 rootUrl 时使用的是 https 而不是 http。