i used the window and android both can call the self signed certificate HTTPS, but ios not (Unable to complete SSL connection) . Any setting or coding can fix it?
public IEnumerator SetGroupID(int id) { string 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 class WebRequestCert : UnityEngine.Networking.CertificateHandler {
protected override bool ValidateCertificate(byte[] certificateData) {
//return base.ValidateCertificate(certificateData);
return true;
//return false;
}
}
A similar question has been asked here. Looks like you have to specify in the Info.plist file that you want to allow "insecure" http connections for the iOS app.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>just-an-example.com</key>
<string></string>
</dict>
</dict>