Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading script from HTTP is automatically converted to HTTPS for some users

Tags:

I am trying to load socket.io using the following code:

<script src="http://cdn.socket.io/socket.io-1.4.5.js"></script>

However some users have reported the following error to me:

Failed to load https://cdn.socket.io/socket.io-1.4.5.js ERR_SSL_PROTOCOL_ERROR

Is this an automatic security setting on modern browsers? And if so can it be disabled?

like image 396
user3024235 Avatar asked Mar 01 '17 04:03

user3024235


People also ask

Why does HTTP change automatically to HTTPS?

HSTS is a security feature that forces the browser to use HTTPS even when accessing an HTTP URL. The browser will start using HSTS for a domain after receiving a Strict-Transport-Security header from the server. The browser also ships with a list of domains for which HSTS is enabled by default.

Can a Web server use both HTTP and HTTPS?

http runs on port 80, and https runs on TCP port 443. They can both be open at the same time, they can even serve different websites.


1 Answers

The problem is not your fault!

Accessing that link in my browser fails as well, and inspecting the unsuccessful request shows that the following header was set:

Upgrade-Insecure-Requests: 1

This tells the browser to "upgrade" all http:// URLs to https://, which seems to mirror the error your users are reporting.

ERR_SSL_PROTOCOL_ERROR indicates that the SSL certificate for https://cdn.socket.io/ is incorrectly configured and thus the browser (rightly) assumes the worst, and chooses not to trust data served from that domain over the secure protocol. When the domain is configured to "upgrade" insecure requests to secure ones, and secure requests are rejected by the browser, it becomes clear why there is no way to access the content correctly at either URL.

I would contact the administrators of the website and inform them of the problem, or just simply switch to another CDN like Chris Chen suggested:

<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/1.4.5/socket.io.min.js"></‌​script>
like image 52
gyre Avatar answered Sep 22 '22 10:09

gyre