c# - Self hosted WCF using WebSockets is not working using SSL -
i have code in console application. trying connect dev tools chrome, error although problem sure in wcf side:
websocket connection 'wss://127.0.0.1:5650/echo' failed: error in connection establishment: net::err_connection_reset
wss not hitting server code, no exceptions not logs. ws minimum modifications working fine. used microsoft.websockets nuget simplify code:
websockethost server = new websockethost(typeof(echowsservice), new uri("https://127.0.0.1:5650/echo")); var bindingssl = websockethost.createwebsocketbinding(true); server.addwebsocketendpoint(bindingssl); server.open();
i tried custom cert validator, said not hitting code.
now have same code except server.open() in asp.net app using serviceroute, , working pretty fine! yes ssl , self signed cert generated vs iis express:
routetable.routes.add(new serviceroute("echo", new trwebsocketservicefactory(), typeof(echowsservice)));
the browser side is:
var ws = new websocket('wss://127.0.0.1:5650/echo')
in web.config don't have more than
<servicehostingenvironment aspnetcompatibilityenabled="true" multiplesitebindingsenabled="true" />
so why hell not working self hosted wcf in simple console app?
all right, got working self signed cert , cert issued comodo. investigated iis , mimic that, binds port , host @ os level. based result in codeproject post.
1. install certificate in hosting machine. testing proposals using self-signed certificate generated vs iis. can use or make makecert.exe. install in personal→certificates.
2. secure socket. on command line administrator run:
netsh http add sslcert ipport=0.0.0.0:5650 certhash=xxxxxxx.. appid={xxxx-xxx..} certstorename=my netsh http add sslcert hostnameport=domainnamne:5650 certhash=xxxxxxx.. appid={xxxx-xxx..} certstorename=my
where:
- ipport , hostnameport = ip, host or domain , port bind certificate.
- certhash = cert’s thumb print without spaces.
- appid = whatever guid, supposed identify app using it.
- certstorename = path cert, in case means personal→certificates
in windows server 2008, can use *httpcfg.exe*** same proposal. once binds successful can review running:
netsh http show sslcert
we get:
hostname:port : domainname:5650 certificate hash : xxxxxxx.. application id : {xxxx-xxx..} certificate store name : verify client certificate revocation : enabled …
3. accept cert in browser side. this step not needed if have valid trusted certificate.
so make browser accept cert, navigate https://domainname:5650 (domain name must match 1 used bind in step 2) dialog accept cert, in chrome maybe needed navigate https://domainname:5650/service.
and voila, in console can try:
ws = new websocket('wss://domainname:5650/service');
and no exceptions.
Comments
Post a Comment