jeudi 23 juin 2016

OKhttp : SSLProtocolException: SSL handshake terminated

I'm trying to figure out why sometimes I get this error

javax.net.ssl.SSLProtocolException: SSL handshake terminated: ssl=0x60d46c90: Failure in SSL library, usually a protocol error error:1409443E:SSL routines:SSL3_READ_BYTES:tlsv1 alert inappropriate fallback (external/openssl/ssl/s3_pkt.c:1256 0x60d57f40:0x00000003)

enter image description here

the code that makes this request:

private <T> void send(final String url,
                                        final Map<String, String> args,
                                        final RequestCallback<T> callback,
                                        final Parser<T> pParser,
                                        final Context pContext,
                                        final HTTP_METHOD method,
                                        final Map<String, String> headers,
                                        final BODY_TYPE bodyType
)  {

    final Request.Builder builder = getBuilder(url);
    populateHeaders(builder, headers);
    final RequestBody body = getBody(args, bodyType);

    if(method==HTTP_METHOD.POST) {
        builder.post(body);
    } else if(method==HTTP_METHOD.GET) {
        builder.get();
    } else if(method==HTTP_METHOD.PUT) {
        builder.put(body);
    } else if(method==HTTP_METHOD.PATCH) {
        builder.patch(body);
    } else {
        throw new RuntimeException("Please specify correct method name!");
    }

    Request request = builder.build();
    debugRequest(request, whoCalledThisMethod());
    call = client.newCall(request);
    call.enqueue(new StandardRequestCallback(pContext, callback, pParser));
}

I've found that if my app gets this exception, force-closing it, followed by re-launching it, can successfully complete the request... however, a short while later, it fails again with this SSL Exception.

What could be wrong ?

Aucun commentaire:

Enregistrer un commentaire