您是否可以使用具有自签名证书的服务工作者? [英] Can you use a service worker with a self-signed certificate?

查看:525
本文介绍了您是否可以使用具有自签名证书的服务工作者?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用于测试的开发人员服务器。他们拥有SSL自签名证书,允许我们通过HTTPS测试Web应用程序,但有明显的警告证明证书不可验证。

I have developer server that are used for testing. They have SSL self-signed certificates, which allow us to test the web application over HTTPS, but with prominent warnings that the certificates are not verifiable.

这很好,但是我有一个服务工作者使用 navigator.serviceWorker.register抛出错误

That's fine, but I have a Service Worker that throws an error with the navigator.serviceWorker.register


SecurityError:无法注册ServiceWorker:获取脚本时发生SSL证书错误。

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

如何使用服务工作者具有自签名证书的Intranet测试服务器?

How do I use a Service Worker with an intranet testing server which has a self-signed certificate?

推荐答案

作为使用自签名证书的替代方法,您可以启动Chrome或Firefox,它假装某些域是安全的。例如,在Mac上使用Chrome,您可以使用以下功能启动它:

As an alternative to using self-signed certificates, you can launch Chrome or Firefox such that it pretends certain domains are secure. For example, using Chrome on a Mac, you can launch it using:

/ Applications / Google \ Chrome \ Canary.app/Contents / MacOS / Google \ Chrome \ --user-data-dir = / tmp / foo --unsafely-treat-insecure-origin-as-secure = http://www.your.site

服务人员应该在 http://www.your上工作.site

更多信息可以在这里找到:
通过HTTP测试服务工作者的选项

More info can be found here: Options for testing service workers via HTTP

编辑:已更改 - unsafety -... - unsafely -...

这篇关于您是否可以使用具有自签名证书的服务工作者?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆