Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Xamarin ios httpclient geotrust certificate

$
0
0

Hello,

I have an GeoTrust Certificate which is installed on my Server.
When i call my webservice on this Server I always get this Error message back: 403 Forbidden

My PCL Project call something like this:

client = new HttpClient(DependencyService.Get<IWebservice>().ApplyCertificateHttpClient(client));
                        client.BaseAddress = new Uri("https://***/");
                        var contentAT = new StringContent(mobileJSON, Encoding.UTF8, "application/json");
                        var responseAT = await client.PostAsync("***", contentAT);
                        var resultAT = await responseAT.Content.ReadAsStringAsync();

In my iOS Project i call this:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Ssl3;
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;

            NativeMessageHandler clientHandler = new NativeMessageHandler() { ClientCertificateOptions = ClientCertificateOption.Automatic };
            using (var mmstream = new MemoryStream())
            {
                Assembly ass = Assembly.GetExecutingAssembly();
                string[] str = ass.GetManifestResourceNames();
                foreach (string resource in str)
                {
                    if (resource.Contains("SSL"))
                        ass.GetManifestResourceStream(resource).CopyTo(mmstream);
                }

                byte[] b = mmstream.ToArray();

                X509Certificate2 cert = new X509Certificate2(b, "***", X509KeyStorageFlags.DefaultKeySet);
                //clientHandler.CheckCertificateRevocationList = true;

                //clientHandler.ServerCertificateCustomValidationCallback = MyRemoteCertificateValidationCallback;
                clientHandler.ClientCertificates.Add(cert);
                return clientHandler;
            }

Why I cant adding the clientcertificate and why i get the error forbidden?


Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>