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

sslSocketFactory Parameter in Android #60

Open
Dennis-kw-yiu opened this issue Nov 10, 2018 · 5 comments
Open

sslSocketFactory Parameter in Android #60

Dennis-kw-yiu opened this issue Nov 10, 2018 · 5 comments
Labels

Comments

@Dennis-kw-yiu
Copy link

Hi All,

I am new to websocket. I need to connect to a websocket in an android device via wss://. However, I cannot do so, exception is shown as below:

javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.

I saw that I may need to supply the sslSocketFactory. However, I have no idea how to set the parameter. Is there any genius can help or any other approach can solve my problem? Thank you in advance.

@NathanaelA
Copy link
Owner

This error normally occurs if you are using WSS and using a self signed certificate. If you are using a self signed cert; then you do have to setup your own sslSocketFactory...

@Dennis-kw-yiu
Copy link
Author

May I know how to setup the sslSocketFactory?

@sido420
Copy link

sido420 commented Dec 19, 2020

Any updates on this? An example would be truly appreciated.

In my case, its not a self-signed certificate. And, this ZeroSSL certificate works fine from Chrome.

@gayatri-kadam
Copy link

gayatri-kadam commented Mar 22, 2022

Any updates here? I have set up my own sslSocketFactory and passed it as a parameter while creating the WS but it never connects to the server and throws an error. Is there a sample code for reference? The one in this repository does not demonstrate "Advanced Interface".

@NathanaelA
Copy link
Owner

Basically you need to follow any of the tutorials that you would do in Java to setup for self signed cert and how to initialize a SSLSocketFactory for it... And then you pass the sslSocketFactor as the options.sslSocketFactory value when you create a new WebSocket...

const WS = require("@master.technology/websockets");
// Do whatever is needed to configure and create a new sslSocketFactory for your certificate
let mySocket = new WS(URL, {sslSocketFactory: mySslSocketFactory});
// use mySocket....

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

No branches or pull requests

4 participants