Skip to content

no way to handle peer certificates? #754

@jcayzac

Description

@jcayzac

I don't see any way to access req.connection from inside socket.io's authorization callback. Is there any? I need to access the peer certificate to get the identity of the connected user (over wss://)

Currently I must hot-swap Manager.handshakeData for the method below, which adds the peer certificate to the data passed to the authorization callback, but it would be nice to have a clearly defined way.

if (typeof io.Manager.prototype._handshakeDataPC !== "function") {
    io.Manager.prototype._handshakeDataPC = io.Manager.prototype.handshakeData
    io.Manager.prototype.handshakeData = function(data) {
        var d = this._handshakeDataPC(data),
            connection = data.request.connection
        d['peer certificate'] = connection.authorized ? connection.getPeerCertificate() : null
        return d
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions