Skip to content

Issue in SSL implementation : protocole ws:// is always use in Draft_76.java #294

@snooze67

Description

@snooze67

hi,

First thank's a lot for this project and library.
I test the ssl implementation and got some issues with Safari on windows and ipad (chrome and safari)

I found why.
In Draft_76.java on the method postProcessHandshakeResponseAsServer

There is always the ws:// protocol.

But on the ssl we need to specify wss:// protocol instead

Don't know how to fix it properly.

So i modify the code that way, passwing the fact to use ws or wss in the ressourceDescriptor

public HandshakeBuilder postProcessHandshakeResponseAsServer( ClientHandshake request, ServerHandshakeBuilder response ) throws InvalidHandshakeException {
                String protocole = "ws://";    

                if(request.getResourceDescriptor().equals("/wss"))
                    protocole = "wss://";

                response.setHttpStatusMessage( "WebSocket Protocol Handshake" );
        response.put( "Upgrade", "WebSocket" );
        response.put( "Connection", request.getFieldValue( "Connection" ) ); // to respond to a Connection keep alive
        response.put( "Sec-WebSocket-Origin", request.getFieldValue( "Origin" ) );

        String location = protocole + request.getFieldValue( "Host" ) + request.getResourceDescriptor();
        response.put( "Sec-WebSocket-Location", location );
        String key1 = request.getFieldValue( "Sec-WebSocket-Key1" );
        String key2 = request.getFieldValue( "Sec-WebSocket-Key2" );
        byte[] key3 = request.getContent();
        if( key1 == null || key2 == null || key3 == null || key3.length != 8 ) {
            throw new InvalidHandshakeException( "Bad keys" );
        }
        response.setContent( createChallenge( key1, key2, key3 ) );
        return response;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions