ssl - 如何绕过 Angular2-Nativescript 上的 SSL 错误?
问题描述
我是 NativeScript 的新手,所以我需要帮助绕过 iOS 和 Android。我试着在谷歌上寻找,但我已经筋疲力尽地试图找到一个足以满足 Angular2+ 的解决方案。
我有一个来自 GoDaddy 的通配符 SSL 证书,所以我不能使用 nativescript-https(根据他们的 github 问题 https://github.com/gethuman/nativescript-https/issues/14)。
一个真实的例子,我可以阅读代码并了解一切发生的地方会很棒,我的意思是,我尝试查看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)",
解决方案
推荐阅读
- spring - Spring:从上下文中排除一些属性文件
- java - Tomcat 9 webapp 的 InetAddress.getByName 不工作 (java.net.UnknownHostException)
- c - 使用C中的比较函数递归地插入二叉搜索树
- php - Laravel Linux php artisan 打不开
- matlab - MATLAB 中的花式相关图
- javascript - 从数组中找到的唯一元素创建新数组
- python - 检索谷歌搜索链接的 Xpath
- php - 输入中的意外字符:第8行/homepages/1/d835516322/htdocs/vitruvium/first.php中的 '\' (ASCII=92) state=1
- file-upload - Wagtail ImageChooserPanel:仅上传,不显示集合中的其他图像
- android - Flutter:尝试在 AppCenter 中构建时出现 appcenter:verifyReleaseResources 错误