Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only secure origins are allowed? #6

Closed
mmocny opened this issue Feb 24, 2015 · 26 comments
Closed

Only secure origins are allowed? #6

mmocny opened this issue Feb 24, 2015 · 26 comments

Comments

@mmocny
Copy link

mmocny commented Feb 24, 2015

When I follow the instructions from Step 1, I end up with a runtime exception and no service worker due to SSL requirement:

Uncaught (in promise) DOMException: Only secure origins are allowed. http://goo.gl/lq4gCo

I even attempted to create a self-signed cert and got http-server to serve ssl, then ignored the big red warning inside chrome, but I still get an error:

Uncaught (in promise) DOMException: Operation failed by security issue with code: 18
(In Canary the message is a bit better:)
DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.

I haven't found a flag to get Chrome to run in a way that accepts all certs, (--disable-web-security isn't it..).

So: Is there any way to test locally that doesn't involve registering an actually valid signed certificate? I know that process has gotten easier, but...

@jakearchibald
Copy link
Owner

localhost is an exception to the TLS rule. What was the url you were
accessing?

On Tue, 24 Feb 2015 22:00 Michal Mocny notifications@github.com wrote:

When I follow the instructions from Step 1, I end up with a runtime
exception and no service worker due to SSL requirement:

Uncaught (in promise) DOMException: Only secure origins are allowed.
http://goo.gl/lq4gCo

I even attempted to create a self-signed cert and got http-server to
serve ssl, then ignored the big red warning inside chrome, but I still get
an error:

Uncaught (in promise) DOMException: Operation failed by security issue
with code: 18
(In Canary the message is a bit better:)
DOMException: Failed to register a ServiceWorker: An SSL certificate error
occurred when fetching the script.

I haven't found a flag to get Chrome to run in a way that accepts all
certs, (--disable-web-security isn't it..).

So: Is there any way to test locally that doesn't involve registering an
actually valid signed certificate? I know that process has gotten easier,
but...


Reply to this email directly or view it on GitHub
#6.

@mmocny
Copy link
Author

mmocny commented Feb 24, 2015

Ah. Was using ip explicitly: 0.0.0.0 or 127.0.0.1 i forget. Thanks!

On Tue, 24 Feb 2015 17:25 Jake Archibald notifications@github.com wrote:

localhost is an exception to the TLS rule. What was the url you were
accessing?

On Tue, 24 Feb 2015 22:00 Michal Mocny notifications@github.com wrote:

When I follow the instructions from Step 1, I end up with a runtime
exception and no service worker due to SSL requirement:

Uncaught (in promise) DOMException: Only secure origins are allowed.
http://goo.gl/lq4gCo

I even attempted to create a self-signed cert and got http-server to
serve ssl, then ignored the big red warning inside chrome, but I still
get
an error:

Uncaught (in promise) DOMException: Operation failed by security issue
with code: 18
(In Canary the message is a bit better:)
DOMException: Failed to register a ServiceWorker: An SSL certificate
error
occurred when fetching the script.

I haven't found a flag to get Chrome to run in a way that accepts all
certs, (--disable-web-security isn't it..).

So: Is there any way to test locally that doesn't involve registering an
actually valid signed certificate? I know that process has gotten easier,
but...


Reply to this email directly or view it on GitHub
<#6
.


Reply to this email directly or view it on GitHub
#6 (comment)
.

@mmocny mmocny closed this as completed Feb 24, 2015
@jakearchibald
Copy link
Owner

127.0.0.1 should also be fine. I don't think 0.0.0.0 works in Chrome.

@mmocny
Copy link
Author

mmocny commented Feb 25, 2015

Confirmed 127.0.0.1 also works. Seems I used 0.0.0.0 because thats the address I set to host http-server on, and Chrome does resolve that to localhost just fine, but without the TLS exception.

@mariusGundersen
Copy link

Does this only work for port 80?

@jakearchibald
Copy link
Owner

Any port is fine

On Fri, 27 Mar 2015 08:34 Marius Gundersen notifications@github.com wrote:

Does this only work for port 80?


Reply to this email directly or view it on GitHub
#6 (comment)
.

@mariusGundersen
Copy link

Hmm, still getting an error:

GET http://127.0.0.1/sw.js net::ERR_INSECURE_RESPONSE

Operation failed by security issue

@jakearchibald
Copy link
Owner

Are you running your own server or the one recommended in the tutorial?

Is the script served with a valid js mime type, eg application/javascript?

On Fri, 27 Mar 2015 08:39 Marius Gundersen notifications@github.com wrote:

Hmm, still getting an error:

GET http://127.0.0.1/sw.js net::ERR_INSECURE_RESPONSE

Operation failed by security issue


Reply to this email directly or view it on GitHub
#6 (comment)
.

@mariusGundersen
Copy link

Thank you, that was the issue!

For anyone ending up here from Google:

    if(path.extname(filename) == '.js'){
      res.setHeader('content-type', 'application/javascript');
    }

@jakearchibald
Copy link
Owner

Will get that error message improved

On Fri, 27 Mar 2015 08:51 Marius Gundersen notifications@github.com wrote:

Thank you, that was the issue!

For anyone ending up here from Google:

if(path.extname(filename) == '.js'){
  res.setHeader('content-type', 'application/javascript');
}


Reply to this email directly or view it on GitHub
#6 (comment)
.

@matthewsibigtroth
Copy link

Greetings!
Here is the remote node server I am currently using:

var https = require("https");
var fs = require("fs");
var key_file = "sslKey.pem";
var cert_file = "sslCert.crt";
var passphrase = "";
var config = {
key: fs.readFileSync(key_file),
cert: fs.readFileSync(cert_file)
};
https.createServer(config, app).listen(443);

However, when i call "navigator.serviceWorker.register" against the worker script sw.js, the following is output to the browser console:

Uncaught (in promise) DOMException: Operation failed by security issue {message: "Operation failed by security issue", name: "SecurityError", code: 18, INDEX_SIZE_ERR: 1, DOMSTRING_SIZE_ERR: 2…}code: 18message: "Operation failed by security issue"name: "SecurityError"proto: DOMException

If I do a straight import of the sw.js using a script tag, the "application/javascript" type exists.

Seems like it's close, but for whatever reason the script won't register. I was curious if there were other configurations needed to help coax sw.js to be well received?

Thank you!

@hasanraz
Copy link

Hi Jack,

I m getting
SecurityError:Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.
Error while registering sw.js by https://localhost:443 .
I had configured openssl with apache taking help from http://rubayathasan.com/tutorial/apache-ssl-on-windows/ . Even then I do not understand why the error is occuring. Please help me to get out of this as I had make a demo on service worker usage for our project.

@isaldarriaga
Copy link

Using polymer and trying to serve the app by using the browsersync's "https: true" option in gulpfile.js. This work and defaults the website to https, but doesn't do anything about trusting a certificate. So the "failed to register a service worker. An ssl certificate error occurred when fetching the script" is thrown in the desktop under this scenario.

I'm doing this because i want to replicate the same situation happening in the mobile browser (chrome). i figured it out through remote inspection. Since the access to the app is made through the IP address of the server, no localhost SSL skip process is made in the browser. same error occur.

If you know a way to trust the certificate by using gulp, please let me know.

@akyoto
Copy link

akyoto commented Jan 9, 2016

Same error:

https://localhost:5001/service-worker.js

ServiceWorker registration failed: DOMException: Failed to register a ServiceWorker: An SSL certificate error occurred when fetching the script.

Content type is application/javascript.
I can't test the script locally.

@averetennikov
Copy link

You can)
Use http://127.0.0.1:5001/service-worker.js
or
http://0.0.0.0:5001/service-worker.js

@Sawtaytoes
Copy link

I'm having the same issue with IIS and a self-signed cert at work:

There are issues with the site's certificate chain (net::ERR_CERT_COMMON_NAME_INVALID).

It'd be nice to have a way to disable this check either in the browser or in the webserver or on the page itself when loading up the service worker such as:

navigator.serviceWorker.register('sw.js', { insecure: true })

@valerybugakov
Copy link

If you still have this problem check out this thread

@jakearchibald
Copy link
Owner

jakearchibald commented Aug 14, 2016

You can launch Chrome with --ignore-certificate-errors if you're using self-signed certs.

We'd never allow:

navigator.serviceWorker.register('sw.js', { insecure: true })

…as you break security by allowing a developer to opt out of it on behalf of the user.

@anacrolix
Copy link

Can you make localhost trusted, or allow service workers over HTTP on localhost, like with other resources?

@leggsimon
Copy link

Not sure if the best place for this but it is possible to add a new secure origin. The reason for this is that we use local.ft.com as our localhost in order to access our flags so it would be good to allow that.

@0xcaff
Copy link

0xcaff commented Jul 7, 2017

I develop on a remote machine and I have this same issue.

@mdmcginn
Copy link

mdmcginn commented Oct 2, 2017

Chrome is giving me a message that --ignore-certificate-errors is unsupported and unstable, but --allow-insecure-localhost seems to work.

@toxaq
Copy link

toxaq commented Oct 16, 2017

Would be great if Chrome just allowed any domain name that resolved to 127.0.0.1. I use the lvh.me domain for testing subdomains so can't just use the IP or localhost.

@rummykhan
Copy link

rummykhan commented Nov 13, 2017

I'm using a vagrant machine for development and it gives me this error. I don't know IMHO even the private ips should be allowed.

@akyoto
Copy link

akyoto commented Nov 14, 2017

Any domain that resolves to localhost / 127.0.0.1 should automagically activate --ignore-certificate-errors.

@designinsist
Copy link

I don't have SSl on my domain can i register a service worker ??
Even i don't have self signed SSl !

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests