0

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.

BytesGuy
  • 4,097
  • 6
  • 36
  • 55
  • This looks like a certificate configuration problem on your server. What do you see if you hit the URL from within Safari on the iOS device you are testing? – Krumelur Aug 08 '16 at 06:55
  • First i got Certificates Warning, but after accepting them i can connect to the webservice. I thought the same and think that i had to give the NSUrlConnection the information die Accept that warning. – Mel-Norman Gerhardt Aug 08 '16 at 07:48
  • Does this help? http://stackoverflow.com/questions/23241872/nsurlconnection-cfurlconnection-http-load-failed-kcfstreamerrordomainssl-9813 – Krumelur Aug 08 '16 at 09:43
  • the entries to info.plist i added, but without success. The information i should add in the app delegate dont work for me either, but maybe i made a mistake or do it wrong. + (BOOL)allowsAnyHTTPSCertificateForHost:(NSString *)host { return YES; } – Mel-Norman Gerhardt Aug 08 '16 at 10:04
  • I think the -9813 error is an Invalid certificate message which refers to a broken chain to a valid root certificate. This is typically found when the SSL cert is improperly created. https://developer.apple.com/library/ios/technotes/tn2232/_index.html//apple_ref/doc/navigation/ – gro Aug 26 '16 at 20:55

0 Answers0