javaandroidbranch.io

BranchSDK: User session has not been initialized


I have problem with BranchSDK, during initialization i receive error:

12-28 13:50:22.203 D/FirebasePerformance: Logging NetworkRequestMetric - https://api2.branch.io/v1/install 0b 1136ms, 12-28 13:50:22.204 I/FirebasePerformance: Did not receive a HTTP Response Code 12-28 13:50:22.204 W/FirebasePerformance: Unable to process the PerfMetric due to missing or invalid values. See earlier log statements for additional information on the specific missing/invalid values. 12-28 13:50:22.208 E/BranchNetworkClient: Error in doRestfulGet(https://api2.branch.io/v1/install) javax.net.ssl.SSLHandshakeException: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x63395a88: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:744 0x5d9ce808:0x00000000) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:449) at okhttp3.internal.connection.RealConnection.connectTls(RealConnection.java:318) at okhttp3.internal.connection.RealConnection.establishProtocol(RealConnection.java:282) at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:167) at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257) at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135) at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114) at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147) at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200) at okhttp3.RealCall.execute(RealCall.java:77) at com.google.firebase.perf.network.FirebasePerfOkHttpClient.execute(Unknown Source) at com.riversoft.eventssion.network.BranchNetworkClient.doRestfulPost(BranchNetworkClient.java:59) at io.branch.referral.network.BranchRemoteInterface.make_restful_post(BranchRemoteInterface.java:136) at io.branch.referral.Branch$BranchPostTask.doInBackground(Branch.java:2860) at io.branch.referral.Branch$BranchPostTask.doInBackground(Branch.java:2835) at android.os.AsyncTask$2.call(AsyncTask.java:288) at java.util.concurrent.FutureTask.run(FutureTask.java:237) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) at java.lang.Thread.run(Thread.java:841) Caused by: javax.net.ssl.SSLProtocolException: SSL handshake aborted: ssl=0x63395a88: Failure in SSL library, usually a protocol error error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure (external/openssl/ssl/s23_clnt.c:744 0x5d9ce808:0x00000000) at com.android.org.conscrypt.NativeCrypto.SSL_do_handshake(Native Method) at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:406) ... 29 more

I tried: https://github.com/BranchMetrics/android-branch-deep-linking/issues/552 and:

ConnectionSpec spec = new 
ConnectionSpec.Builder(ConnectionSpec.MODERN_TLS)  
    .tlsVersions(TlsVersion.TLS_1_2)
    .cipherSuites(
          CipherSuite.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
          CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
          CipherSuite.TLS_DHE_RSA_WITH_AES_128_GCM_SHA256)
    .build();

OkHttpClient client = new OkHttpClient.Builder() 
    .connectionSpecs(Collections.singletonList(spec))
    .build();

P.S. This is problem is on API19, but API 28, 27, 25, 23 all is good worked.


Solution

  • For version 3.0.3 and below, helped me only add a string when initializing the BranchSDK: ProviderInstaller.installIfNeeded(context);