在ios上,在离子混合应用程序中,如何绕过证书检查(使用自签名证书) [英] On ios, in ionic hybrid app, how to bypass certificate check (using self-signed certificates)

查看:484
本文介绍了在ios上,在离子混合应用程序中,如何绕过证书检查(使用自签名证书)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的离子/ cordova app现在在与HTTPS后端一起使用时出错

My ionic/cordova app now gives errors when used with HTTPS backend

`The certificate for this server is invalid`

我在我的开发环境中,使用自签名证书,并使用IP地址连接后端。

I am in my development environment, use self-signed certificates, and use IP address to connect with the backend.

我使用 openssl s_client 检查证书,看起来有效。事实上,我可以使用与这个混合应用程序的Android版本相同的后端。

I examined the certificate using openssl s_client and it looks valid. As a matter of fact I am able to use the same backend with android version of this hybrid app.

是否有一些 plist 或其他 Xcode 设置接受自签名证书或一起忽略此测试 - 类似于 NSAppTransportSecurity :: NSAllowsArbitraryLoads 设置?

Is there some plist or other Xcode setting to accept a self-signed certificate or ignore this test all together - similar to NSAppTransportSecurity::NSAllowsArbitraryLoads setting?

- 编辑

我有<访问来源我的 config.xml 文件中包含=*/>

I have <access origin="*"/> in my config.xml file.

谢谢很多

推荐答案

您可以在AppDelegate.m的末尾添加它,但仅出于测试目的,您应该先删除它发布应用程序时,苹果可能不会批准应用程序,如果它包含该代码

You can add this at the end of AppDelegate.m, but just for testing purposes, you should remove it before releasing the app, apple might not approve the app if it contains that code

@implementation NSURLRequest(DataController)
+ (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host
{
    return YES;
}
@end

这篇关于在ios上,在离子混合应用程序中,如何绕过证书检查(使用自签名证书)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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