gpt4 book ai didi

ios - Unity IOS 应用无法使用 UnityWebRequest 调用自签名证书 HTTPS

转载 作者:行者123 更新时间:2023-12-04 22:42:41 24 4
gpt4 key购买 nike

我用window和android都可以调用自签名证书HTTPS,但ios不行(无法完成SSL连接)。任何设置或编码都可以解决它?
公共(public) IEnumerator SetGroupID(int id) {
字符串 url = AppConfig.APIDomain + "/Game/setGroupID/"+ id;

    Debug.Log("Check color URL : " + url);
using (UnityWebRequest webRequest = UnityWebRequest.Get(url)) {
// Request and wait for the desired page.
webRequest.certificateHandler = new WebRequestCert();

yield return webRequest.SendWebRequest();
string[] pages = url.Split('/');
int page = pages.Length - 1;

if (webRequest.isNetworkError) {
Debug.Log(pages[page] + ": Error: " + webRequest.error);
GameMainMenuUI.Instance.OhError(webRequest.error);
}
else {
try {
Debug.Log(webRequest.downloadHandler.text);
}
catch (Exception e) {
GameMainMenuUI.Instance.OhError("Get Init Data Failed : "+e);
}
}
}

}
公共(public)类 WebRequestCert : UnityEngine.Networking.CertificateHandler {
protected override bool ValidateCertificate(byte[] certificateData) {
//return base.ValidateCertificate(certificateData);
return true;

//return false;
}
}

最佳答案

有人问过类似的问题 here .看起来您必须在 Info.plist 文件中指定要允许 iOS 应用程序的“不安全”http 连接。

<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>just-an-example.com</key>
<string></string>
</dict>
</dict>

关于ios - Unity IOS 应用无法使用 UnityWebRequest 调用自签名证书 HTTPS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64421319/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com