1

所以我有一个网页,我试图通过 HttpsURLConnection 访问它。颁发的证书是由 Digicert CA-3 颁发的。但是我总是得到 400 的响应。android 开发者网站,维基百科示例工作正常。这个网站也在设备上的 chrome 上打开。我想知道这是否是一个问题我如何调用电话。或者可能是什么问题

    URL url = new URL(strUrl);
    HttpsURLConnection urlConnection = (HttpsURLConnection) url
            .openConnection();
    SSLContext sslcontext = SSLContext.getDefault();
    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeAllCookie();
    urlConnection.setDoOutput(false);
    urlConnection.setDoInput(true);
    urlConnection.setSSLSocketFactory(sslcontext.getSocketFactory());
    int code = urlConnection.getResponseCode(); //always 400 :(
4

1 回答 1

0

可能你应该仔细检查你正在使用的 URL。这主要是因为客户的错误请求。

于 2014-08-07T09:20:27.167 回答