Forum Xamarin.iOS

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

HTTPClient - API working on one iPad and not another with same confirguration

I am consuming an "https://www.******pi.********^$%.org.uk" which is working one iPAD and is not working another. I have the same configuration device (Software and Hardware). I am connected to same network. This API call works with some iPad and not working with some iPad having same OS and configuration.

It is a random behavior on iOS Devices to come on any conclusion. It is working completely fine in Android.

I am working on Xamarin Native and have tried following solutions but have not succeeded -

https://medium.com/outsystems-engineering/installing-a-valid-certificate-on-a-dev-server-433e499260fe

https://stackoverflow.com/questions/33128240/connect-to-a-server-with-invalid-certificate-using-nsurlsession-swift2-xcode7-i

https://stackoverflow.com/questions/47664218/trust-a-self-signed-certificate-using-httpclient

Below is issue which I am getting -

{System.Net.WebException: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “**&^&^&%^.(&^(&^^&.org.uk” which could put your confidential information at risk. ---> Foundation.NSErrorException: Exception of type 'Foundation.NSErrorException' was thrown. --- End of inner exception stack trace --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:152 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535 at System.Net.Http.NSUrlSessionHandler+d__29.MoveNext () [0x001c3] in /Users/builder/data/lanes/5944/64fece5f/source/xamarin-macios/src/Foundation/NSUrlSessionHandler.cs:202`

Answers

  • seanydaseanyda GBMember ✭✭✭✭✭

    Try adding this to your info.plist source.

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

    This was a requirement for https (introduced in iOS 10 I think), if the OS version is different on the iPads that might explain why only one is working with the https url and not the other.

  • RaviKanasagraRaviKanasagra INMember ✭✭

    OS version is same on both iPads.

  • FizzgigFizzgig Member

    Was any solution found for this?
    I'm experiencing the same problem.

Sign In or Register to comment.