Skip to content

Support wss with self-signed certificate #257

Open
@cedricshih

Description

@cedricshih

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!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions