Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebSocket on IE10 giving a SecurityError

I am currently developing a website under IE10 (on Windows 8), using WebSockets in JavaScript. It runs fine under Firefox 18 and Chrome 25, but on IE10 I get a SecurityError when I establish the connection.

What I am doing seems pretty straghtforward :

websocket = new WebSocket('wss://hello.dev.mydomain.net');

But IE doesn't like it :

SCRIPT5022: SecurityError 

The script is on "https://test.dev.mydomain.net" (not the real address obviously).

What bothers me is that if I just double-click the file on my local computer (e.g. file://...) it just works. Even worse: if I use fiddler to monitor HTTP traffic... it also works. Whereas there seems to be no connection at all without fiddler, as detailed in the API's specs. (See below.)

Judging by websocket spec, the exception should also appear on Chrome/Firefox... but it does not. So I doubt it has anything related to HTTP/HTTPS. In any case, I am using a wsS socket on a httpS page... Moreover: when I replace the wss address by another valid server found on an online example, it works.

I don't know if this is relevant, but the IP from test.dev.mydomain.net is 10.14.x.x where hello.dev.mydomain.net is 194.247.x.x. I don't know if it could trigger some kind of security on IE only...

One more thing: I have a certificate for *.dev.mydomain.net, IE does not seems to have problems with it. The script originally resides on a server called my.name.dev.mydomain.net, but since I am accessing it from another URL (I got a redirect since we first thought it could have been some kind of Same Origin Policy issue), I don't see how it could matter. At least I hope it does not...

Any idea is welcomed.

EDIT: adding the sites to the trusted zone does not work either.

like image 477
EldredB Avatar asked Feb 27 '13 14:02

EldredB


2 Answers

It looks like IE throws a SecurityError if you're trying to open a websocket on a local (intranet) domain. To overcome this, you may disable IE's automatic algorithm for recognizing local sites. This can be done in Tools > Internet Options > Security > Local Intranet > Sites.

intranet detection settings

Uncheck all checkboxes (or only a particular one, if you know how exactly your domain did end up in intranet ones).

Note that IE uses (among other things) its proxy settings to determine local sites: if your domain is listed as excluded from proxying in proxy settings, then it will probably be treated as intranet one. This is why WebSockets work if you enable Fiddler: it modifies IE proxy settings and thus the list of intranet sites changes.

like image 129
Georgii Ivankin Avatar answered Oct 22 '22 10:10

Georgii Ivankin


I had this problem in Windows7/IE11 after applying a security patch. For Windows10/Edge is the same story.

As this is a local websocket (ws://localhost) you have to add ws:\\localhost\ to Internet Explorer configurations (Tools > Internet Options > Security > Local Intranet > Sites > Advanced).

IE11 local intranet sites configuration

In Windows 10/Microsoft Edge you will find this configuration in Control Panel > Internet Options.

UPDATE

The address of your webapp (https://test.dev.mydomain.net) must be added to the local intranet zone too. Note that in the image the webapp address should be added.

like image 16
lmiguelmh Avatar answered Oct 22 '22 08:10

lmiguelmh