android - SSL Exception when using Volley -


i'm using volley in android perform app requests. unfortunately, i'm getting following error:

com.android.volley.noconnectionerror: javax.net.ssl.sslhandshakeexception: javax.net.ssl.sslprotocolexception: ssl handshake aborted: ssl=0x61e15f78: failure in ssl library, protocol error     error:1407743e:ssl routines:ssl23_get_server_hello:tlsv1 alert inappropriate fallback (external/openssl/ssl/s23_clnt.c:744 0x5b647c58:0x00000000) 

i'm using 2 fragments, inside viewpager, request content during onresume. requests url same query parameter (which set type of content, e.g. trending vs hot).

the url in form https://host/api/content?type={hot/trending}. authorization done through request header.

the weird part exception 1 of 2 requests fail , varies 1 time time. after added delay between them, exception stopped occurring (oddly pointing race condition?). seems bad workaround , i'd solve right way.

any thoughts on cause of it?

edit:

the request created standard way, using singleton providing queue, follows:

final requestqueue requestqueue = requestqueuesingleton.getinstance(getactivity()).getrequestqueue(); final gsonrequestget<searchapiwrapper> gsonrequest = new gsonrequestget<>(clazz, url,successlistener, errorlistener); gsonrequest.setretrypolicy(new defaultretrypolicy(3000, 3, defaultretrypolicy.default_backoff_mult)); gsonrequest.settag(mtag); requestqueue.add(gsonrequest); 

and here singleton class:

public class requestqueuesingleton {      private static requestqueuesingleton minstance;     private requestqueue mrequestqueue;     private context mcontext;      public requestqueuesingleton(context context) {         mcontext = context;         mrequestqueue = getrequestqueue();     }      /**      * returns instance of singleton      */     public static synchronized requestqueuesingleton getinstance(context context) {         if (minstance == null) {             minstance = new requestqueuesingleton(context);         }         return minstance;     }      /**      * returns instance of request queue      */     public requestqueue getrequestqueue() {         if (mrequestqueue == null) {             mrequestqueue = volley.newrequestqueue(mcontext.getapplicationcontext());         }         return mrequestqueue;     } } 

after our comments maybe can you:

your requestqueue:

static {     requestqueue = volley.newrequestqueue(application.getcontext(), new hurlstack(null, clientsslsocketfactory.getsocketfactory())); } 

the clientsslsocketfactory:

public class clientsslsocketfactory extends sslcertificatesocketfactory {     private sslcontext sslcontext;      public static sslsocketfactory getsocketfactory(){         try         {             x509trustmanager tm = new x509trustmanager() {                 public void checkclienttrusted(x509certificate[] xcs, string string) throws certificateexception {}                  public void checkservertrusted(x509certificate[] xcs, string string) throws certificateexception {}                  public x509certificate[] getacceptedissuers() {                     return null;                 }             };             sslcontext = sslcontext.getinstance("tls");             sslcontext.init(null, new trustmanager[] { tm }, null);              sslsocketfactory ssf = clientsslsocketfactory.getdefault(10000, new sslsessioncache(application.getinstance()));              return ssf;         } catch (exception ex) {             return null;         }     }      @override     public socket createsocket(socket socket, string host, int port, boolean autoclose) throws ioexception, unknownhostexception {         return sslcontext.getsocketfactory().createsocket(socket, host, port, autoclose);     }      @override     public socket createsocket() throws ioexception {         return sslcontext.getsocketfactory().createsocket();     } } 

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -