【发布时间】:2019-01-09 00:25:25
【问题描述】:
我是 NativeScript 的新手,所以我需要帮助绕过 iOS 和 Android。我尝试在 google 上查找,但我已经筋疲力尽地试图找到一个足以满足 Angular2+ 的解决方案。
我有一个来自 GoDaddy 的通配符 SSL 证书,所以我不能使用 nativescript-https(https://github.com/gethuman/nativescript-https/issues/14 per their github issue)。
一个真实的例子,我可以阅读代码并了解一切发生的地方会很棒,我的意思是,我尝试查看https://discourse.nativescript.org/t/how-to-ignore-invalid-ssl-certificate-in-nativescript/1924,但这对我来说没有任何意义,因为我不知道在哪里使用此示例时从代码开始。
编辑: 我尝试使用 nativescript-https disableSSLPining,没有成功。 在我的 app.module.ts
import * as application from 'application';
import * as platform from 'platform';
import * as HTTPS from 'nativescript-https';
var disabledSSLError = () => {
if(platform.isAndroid){
application.android.startActivity = () => {
HTTPS.disableSSLPinning();
}
}
};
disabledSSLError();
但是,当我发送 POST 时
"message": "Http failure response for (unknown url): 0 Unknown Error",
JS: "error": {
JS: "originalStack": "Error: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.\n at new ZoneAwareError (file:///data/data/org.nativescript.myapp/files/app/tns_modules/nativescript-angular/zone-js/dist/zone-nativescript.js:1298:33)\n at onRequestComplete (file:///data/data/org.nativescript.myapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:45:34)\n at Object.onComplete (file:///data/data/org.nativescript.myapp/files/app/tns_modules/tns-core-modules/http/http-request/http-request.js:37:13)",
【问题讨论】: