簡體   English   中英

在ios上,在離子混合應用程序中,如何繞過證書檢查(使用自簽名證書)

[英]On ios, in ionic hybrid app, how to bypass certificate check (using self-signed certificates)

我的離子/ cordova應用程序現在在與HTTPS后端一起使用時會出錯

`The certificate for this server is invalid`

我在我的開發環境中,使用自簽名證書,並使用IP地址連接后端。

我使用openssl s_client檢查了證書,看起來有效。 事實上,我可以使用與這個混合應用程序的Android版本相同的后端。

是否有一些plist或其他Xcode設置接受自簽名證書或一起忽略此測試 - 類似於NSAppTransportSecurity::NSAllowsArbitraryLoads設置?

- 編輯

我在config.xml文件中有<access origin="*"/>

非常感謝

您可以在AppDelegate.m的末尾添加它,但僅出於測試目的,您應該在發布應用程序之前將其刪除,如果應用程序包含該代碼,Apple可能不會批准該應用程序

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

嘗試將此添加到info.plist

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

您也可以在這里查看一些解決方法

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM