Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support wss with self-signed certificate #257

Open
cedricshih opened this issue Aug 3, 2017 · 2 comments
Open

Support wss with self-signed certificate #257

cedricshih opened this issue Aug 3, 2017 · 2 comments

Comments

@cedricshih
Copy link

I am currently working on extending this library to accept our self-signed certificate without replacing default socket factory. My current attempt is to add socket factory members in WebSocketOptions.java:

public class WebSocketOptions {
    ...
    private SocketFactory mSocketFactory;
    private SSLSocketFactory mSslSocketFactory;

And initialized with default factories in default constructor:

    public WebSocketOptions() {
        ...
        mSocketFactory = SocketFactory.getDefault();
        mSslSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();

Also copied in clone constructor:

    public WebSocketOptions(WebSocketOptions other) {
        ...
        mSocketFactory = other.mSocketFactory;
        mSslSocketFactory = other.mSslSocketFactory;

Then in WebSocketConnection.java, create socket with factories in WebSocketOptions:

    private class WebSocketConnector extends Thread {

        public void run() {
                ...
                if (mWsScheme.equals("wss")) {
                    mSocket = mOptions.getSslSocketFactory().createSocket();
                } else {
                    mSocket = mOptions.getSocketFactory().createSocket();
                }

Do you accept patches? Or please consider to support this feature in other way. Thanks for your great work!

@oberstet
Copy link
Contributor

we should support TLS client connection options - which as a subproblem includes accepting self-signed certificates.

it is not a websocket options thing though, and it might also very well differ in how it is done in Android vs Netty

fwiw, related: #374

@oberstet
Copy link
Contributor

see also #452

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

No branches or pull requests

2 participants