我想创建一个在IIS上托管的网站,该网站也可以脱机工作,并且只能在我们的本地网络中使用。为此,我想使用有角度的服务人员。
他们需要SSL证书才能在生产中工作。
由于该网站不是公开的,所以我认为我无法使用Let's Encrypt获得正式证书。因此,我使用以下命令使用OpenSSL创建了自签名证书:
openssl> genrsa -des3 -out c:\openssl\selfsigned\server.key 2048
openssl> reg -new -key c:\openssl\selfsigned.server\key -sha256 -out c:\openssl\selfsigned\server.crt
openssl> x509 -req -days 365 -in c:\openssl\selfsigned\server.csr -signkey c:\openssl\selfsigned\server.key -sha256 -out c:\openssl\selfsigned\server.crt
openssl> pkcs12 -export -out c:\openssl\selfsigned\server.pfx -inkey c:\openssl\selfsigned\server.key -in c:\openssl\selfsigned\server.crt
我在IIS上导入了server.pfx,并将其设置为网站的SSL证书。我通过邮件将server.crt发送到装有iOS 12.3的iPad Air 2并进行了安装。
第一次打开网站时,它表示不受信任的网站,但是在选择继续浏览该网站后,它可以正常工作,并且缓存和注册该网站的新版本也可以。
一旦我关闭Safari并再次打开网站,服务工作人员将无法使用。好吧,他们仍然打开旧的缓存版本,但是直到我删除Safari的缓存后,它们才加载新的缓存,因为我将信息保存在localStorage中,所以我不希望使用该缓存。
当我在客户端上打开 / ngsw / state 时,它显示 TypeError(此服务器的证书无效)。
这是我的package.json:
{
"name": "core",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "6.0.0",
"@angular/cdk": "6.0.0",
"@angular/common": "6.0.0",
"@angular/compiler": "6.0.0",
"@angular/core": "6.0.0",
"@angular/forms": "6.0.0",
"@angular/http": "6.0.0",
"@angular/material": "6.0.0",
"@angular/platform-browser": "6.0.0",
"@angular/platform-browser-dynamic": "6.0.0",
"@angular/pwa": "^0.6.8",
"@angular/router": "6.0.0",
"@angular/service-worker": "^6.1.10",
"@auth0/angular-jwt": "^2.1.0",
"@ng-select/ng-select": "2.7.1",
"@zxing/library": "0.7.0",
"@zxing/ngx-scanner": "1.2.0",
"angular-md5": "0.1.10",
"browser-sync": "2.24.4",
"core-js": "2.5.7",
"http-server": "^0.11.1",
"jquery": "3.3.1",
"jquery-ui-dist": "1.12.1",
"jsqr": "1.1.1",
"md5": "2.2.1",
"npm": "6.1.0",
"rxjs": "6.1.0",
"rxjs-compat": "6.2.1",
"web3": "0.20.5",
"zone.js": "0.8.19"
},
"devDependencies": {
"@angular/compiler-cli": "6.0.0",
"@angular-devkit/build-angular": "0.6.8",
"typescript": "2.7.2",
"@angular/cli": "6.0.8",
"@angular/language-service": "6.0.0",
"@types/jasmine": "2.8.8",
"@types/jasminewd2": "~2.0.2",
"@types/node": "10.0.6",
"codelyzer": "4.0.1",
"jasmine-core": "3.1.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "2.0.4",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "1.4.3",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "1.0.0",
"protractor": "5.3.1",
"service-worker-precache-webpack-plugin": "1.3.5",
"ts-node": "6.0.3",
"tslint": "5.10.0"
}
}
是否有更多选择可以使服务工作者在局域网中工作?也许我遗漏了一些东西或犯了一个愚蠢的错误。任何帮助表示赞赏。
谢谢!