node.js - How to be confident that a websocket is secured -
this may sound absurd question , is. right use websocket-node may switch ws soon. answers both implementations welcome.
i open listener on port 8080 , wait connection request. after accepting request want confident connection secured (as in: use wss://
, reject simple ws://
).
the trivial code taken documentation is:
wsserver.on('request', function(request) { // todo: produce single bit ssl_is_active = ?; if (!ssl_is_active) { request.reject(); // ws protocol used, want wss! return; } // ... proceed process request (authentication , on) }
as simple may sound i've not found documentation this.
do have stick ssl port (443) or can still choose port, e.g. using:
wss://localhost:8080/test
is there way test protocol , suffice, e.g. along lines:
request.protocol === "wss" -or- request.uri.indexof("wss://") === 0
it looks i'm missing because it's not possible i'm 1 problem :d
any appreciated both implementations (websocket-node , ws)!
i feel straightforward way ensure no unsecure requests being made not support unsecured requests when constructing server. looks websocket.node
supports secure servers. i'd imagine ws
should too. think there should way bind wss
both projects.
from websocket.node
looks can create tls server using:
tls supported server connections (use https.createserver instead of http.createserver)
Comments
Post a Comment