I'm working on a Xamarin cross platform project which I have to change from http
to https
.
Since the app runs in a Mobile Iron Environment, I have to use a NSUrlConnection
.
Now when I'm trying to use the following code on iOS (which worked with http
), I get the error in the title.
Console.WriteLine("RequestClass not null");
String xmlSerialized= SerializeXML<cRequestClass>(reQuestClass);
byte[] Content = Encoding.UTF8.GetBytes(xmlSerialized);
Console.WriteLine("Class Converted");
var request = new NSMutableUrlRequest(NSUrl.FromString(@WebserverURL), NSUrlRequestCachePolicy.ReloadIgnoringCacheData, 40);
request.HttpMethod = "POST";
request.ShouldHandleCookies = true;
request.Body = NSData.FromArray(Content);
Console.WriteLine("Start Connecting");
Task<NSUrlAsyncResult> result = NSUrlConnection.SendRequestAsync(request, OpsQueue);
Console.WriteLine("Result Received Async");
NSData data = result.Result.Data;
Console.WriteLine("Data transformed");
ReturnValue = data.ToString();
Console.WriteLine(ReturnValue);
Only for development purposes, I tried to add a new key to my info.plist
, but without any results.
<key>NSAppTransportSecurity</key>
<dict>
<key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSIncludesSubdomains</key>
<true/>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
I have been working on it for a week now and only found some java snippets with information on some delegates - willSendRequestForAuthenticationChallenge
, which I couldn't successfully implement.