pwittchen / ReactiveNetwork

Android library listening network connection state and Internet connectivity with RxJava Observables
http://pwittchen.github.io/ReactiveNetwork/docs/RxJava2.x/
Apache License 2.0
2.53k stars 272 forks source link

SSL Support with custom host #325

Open moeindev opened 5 years ago

moeindev commented 5 years ago

Hi, thank you for this amazing library.

I was wondering if this library supports custom SSL connection to observe internet connectivity!

when I want to check the connection with the base URL, https://bluhbluh.bluh it gives me the handshake error...

javax.net.ssl.SSLHandshakeException: Handshake failed

for calling my web APIs, Im using retrofit and custom SSL configuration inline fun <reified T> createWebService(): T { val customTrust = CustomTrust() var client = OkHttpClient.Builder().build() try { client = OkHttpClient.Builder() .sslSocketFactory(customTrust.getSocketFactory(),customTrust.getTrustManager()) .build() Log.i("Security","Ssl initialized") }catch (e: GeneralSecurityException){ Log.e("Security","unable to init ssl") } val gson = GsonBuilder() .setLenient() .create() val retrofit = Retrofit.Builder() .baseUrl(baseUrl) .client(client) .addConverterFactory(GsonConverterFactory.create(gson)) .addCallAdapterFactory(RxJava2CallAdapterFactory.create()).build() return retrofit.create(T::class.java) }

pwittchen commented 5 years ago

It's not explicitly supported now and I haven't tested it for such cases. Nevertheless, I'm open for improvements.