Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Support wss with self-signed certificates in Android #45

Closed
gdurand opened this issue Mar 29, 2018 · 2 comments
Closed

Support wss with self-signed certificates in Android #45

gdurand opened this issue Mar 29, 2018 · 2 comments

Comments

@gdurand
Copy link

gdurand commented Mar 29, 2018

This could be done by allowing to set a default SSLSocketFactory, so we can pass the usual factory with no trustmanager, or even with an explicit support, which would avoid people to manage this kind of thing.

The former is probably better because is allows more control, and you have to go through hoops anyway if you want this support for https (not possible with the android client, so you have to use okhttp directly).

My quick hack:
In the constructor:

this._sslSocketFactory = options.sslSocketFactory;

In _reCreate:

if (isWSS) {
		var socketFactory;
		if (this._sslSocketFactory) {
			socketFactory = this._sslSocketFactory;
		} else {
			//noinspection JSUnresolvedFunction,JSUnresolvedVariable
			var sslContext = javax.net.ssl.SSLContext.getInstance( "TLS" );
			sslContext.init( null, null, null );
			//noinspection JSUnresolvedFunction
			socketFactory = sslContext.getSocketFactory();
			//noinspection JSUnresolvedFunction
		}
		
		this._socket.setSocket( socketFactory.createSocket() );
}
@NathanaelA
Copy link
Owner

Thank you for the idea. I have implemented this in the next version. options.sslSocketFactory can be set on Android to pass in your own socket factory.

@yencolon
Copy link

yencolon commented Jun 2, 2018

This not works for me

Update: I fixed this adding more timeout at the constructor. 👍

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants