当我从Android申请时,我正在从我的应用程序中获取SSL异常

SSL握手异常com.android.volley.o:javax.net.ssl.SSLHandshakeException:java.security.cert.CertPathValidatorException:未找到证书路径的信任锚 .

SSL握手异常com.android.volley.o:javax.net.ssl.SSLHandshakeException:连接被对等关闭

SSL握手异常com.android.volley.o:javax.net.ssl.SSLHandshakeException:握手失败

用户间歇性地出现这些异常 . 我不确定它是否是服务器问题,因为对于相同的服务器,IOS应用程序不会抛出任何SSL错误 .

以上所有异常都是IO异常,并且在下面提到的“BasicNetwork.Java”的突出显示行中出现:

@Override

public NetworkResponse performRequest(Request> request) throws VolleyError {

long requestStart = SystemClock.elapsedRealtime();

while (true) {

HttpResponse httpResponse = null;

byte[] responseContents = null;

Map responseHeaders = Collections.emptyMap();

try {

// Gather headers.

Map headers = new HashMap();

addCacheHeaders(headers, request.getCacheEntry());

httpResponse = mHttpStack.performRequest(request, headers);

StatusLine statusLine = httpResponse.getStatusLine();

int statusCode = statusLine.getStatusCode();

responseHeaders = convertHeaders(httpResponse.getAllHeaders());

// Handle cache validation.

if (statusCode == HttpStatus.SC_NOT_MODIFIED) {

Entry entry = request.getCacheEntry();

if (entry == null) {

return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, null,

responseHeaders, true,

SystemClock.elapsedRealtime() - requestStart);

}

// A HTTP 304 response does not have all header fields. We

// have to use the header fields from the cache entry plus

// the new ones from the response.

// http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.3.5

entry.responseHeaders.putAll(responseHeaders);

return new NetworkResponse(HttpStatus.SC_NOT_MODIFIED, entry.data,

entry.responseHeaders, true,

SystemClock.elapsedRealtime() - requestStart);

}

// Handle moved resources

if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY || statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {

String newUrl = responseHeaders.get("Location");

request.setRedirectUrl(newUrl);

}

// Some responses such as 204s do not have content. We must check.

if (statusCode != HttpStatus.SC_NO_CONTENT && httpResponse.getEntity() != null){

responseContents = entityToBytes(httpResponse.getEntity());

} else {

// Add 0 byte response as a way of honestly representing a

// no-content request.

responseContents = new byte[0];

}

// if the request is slow, log it.

long requestLifetime = SystemClock.elapsedRealtime() - requestStart;

logSlowRequests(requestLifetime, request, responseContents, statusLine);

if (statusCode < 200 || statusCode > 299) {

throw new IOException();

}

return new NetworkResponse(statusCode, responseContents, responseHeaders, false,

SystemClock.elapsedRealtime() - requestStart);

} catch (SocketTimeoutException e) {

attemptRetryOnException("socket", request, new TimeoutError());

} catch (ConnectTimeoutException e) {

attemptRetryOnException("connection", request, new TimeoutError());

} catch (MalformedURLException e) {

throw new RuntimeException("Bad URL " + request.getUrl(), e);

} catch (IOException e) {

int statusCode = 0;

NetworkResponse networkResponse = null;

if (httpResponse != null) {

statusCode = httpResponse.getStatusLine().getStatusCode();

} else {

**throw new NoConnectionError(e);**

}

if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY ||

statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {

VolleyLog.e("Request at %s has been redirected to %s", request.getOriginUrl(), request.getUrl());

} else {

VolleyLog.e("Unexpected response code %d for %s", statusCode, request.getUrl());

}

if (responseContents != null) {

networkResponse = new NetworkResponse(statusCode, responseContents,

responseHeaders, false, SystemClock.elapsedRealtime() - requestStart);

if (statusCode == HttpStatus.SC_UNAUTHORIZED ||

statusCode == HttpStatus.SC_FORBIDDEN) {

attemptRetryOnException("auth",

request, new AuthFailureError(networkResponse));

} else if (statusCode == HttpStatus.SC_MOVED_PERMANENTLY ||

statusCode == HttpStatus.SC_MOVED_TEMPORARILY) {

attemptRetryOnException("redirect",

request, new AuthFailureError(networkResponse));

} else {

// TODO: Only throw ServerError for 5xx status codes.

throw new ServerError(networkResponse);

}

} else {

throw new NetworkError(networkResponse);

}

}

}

}

我想知道这背后的确切原因 .

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐