title: Xamarin Pinning Certificate ServicePointManager Callback does not fire Xamarin android and iOS
body: <p>I have been looking at xamarin pinning certificate and I have tried the code below but  Service callback never gets called.</p>
  
  <p>I just added a button that makes an http call and I was expecting for the callback to be invoked</p>
  
  <p>**using xamarin.forms.4.6.0.800  and .net standard 2.0 **</p>
  
  <p>AppXaml</p>
  
  <pre><code>    protected override async void OnInitialized()
      {
          InitializeComponent();
          CertificateValidator.Initialize();
  
          await NavigationService.NavigateAsync("NavigationPage/MainPage");
      }
  </code></pre>
  
  <p>ViewModel  </p>
  
  <pre><code>public class MainPageViewModel : ViewModelBase
  {
      private readonly HttpClient httpClient;
      public MainPageViewModel(INavigationService navigationService)
          : base(navigationService)
      {
          this.httpClient = new HttpClient(new HttpClientHandler());
      }
  
      private DelegateCommand makeCallCommand;
      public DelegateCommand MakeCallCommand =&gt;
          makeCallCommand ?? (makeCallCommand = new DelegateCommand(async () =&gt; await MakeCall()));
  
      async Task MakeCall()
      {
         var result= await httpClient.GetStringAsync("https://www.xamarin.com");
      }
  }
  </code></pre>
  
  <p>CertificateValidator</p>
  
  <pre><code>public static class CertificateValidator
  {
  
      private const string PublicKey = "whatever";
  
  
      public static void Initialize()
      {
          ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
          ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate;
      }
  
      public static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
      {
          Debugger.Break();
          return PublicKey == certificate?.GetPublicKeyString();
      }
  }
  </code></pre>
  
  <p>In Android I have tried all below and none trigger a callback .</p>
  
  <p>Happy to use native handlers but not sure where to start. Is there a nuget?</p>
  
  <p><a href="https://i.stack.imgur.com/uCgwn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uCgwn.png" alt="enter image description here"></a></p>