1

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.

API call has been done using HttpClient class. It is working completely fine in Android.

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.

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

Connect to a Server with Invalid Certificate using NSURLSession (swift2,xcode7,ios9)

Trust a self signed certificate using Httpclient

System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

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.ConfiguredTaskAwaitable`1+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

Any help is appreciated.

Ravi Kanasagra
  • 591
  • 1
  • 8
  • 22
Tushar Limaye
  • 106
  • 2
  • 7
  • Are all the devices using the same iOS version? Also I would add the code that you are using to your question (i.e. using a custom NSUrlSession with Xamarin's NSUrlSessionHandler, or ?....) Also have you directly used `NSUrlSession` instead of HttpClient to rule out Xamarin as the issue? In the end, avoiding self-signed certs all together is the way to go... SSL certs are available for free... ;-) – SushiHangover Aug 22 '18 at 06:28
  • Check the date and time on your iPad. If the clock is too skewed, then TLS negotiation will fail – Paulw11 Aug 23 '18 at 01:54
  • @Sushi I have tried using NURLSession and it is not working. – Tushar Limaye Aug 23 '18 at 05:16
  • @Paulw11 I have checked for that. That is correct – Tushar Limaye Aug 23 '18 at 05:16

1 Answers1

0

"The certificate for this server is invalid." You have to install a trusted certificate on the server.

Another option is to put this into the AppDelegate: System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };

It will effectively ignore the certificate validation process (but is not recommended for production!)

Csharpest
  • 1,258
  • 14
  • 32