How does RestSharp add a client certificate to an Https request? (FROM#)

How does RestSharp add a client certificate to an Https request? My code is not working.

public static IRestResponse<User> AsyncHttpRequestLogIn(string path, string method, object obj) { var client = new RestClient(Constants.BASE_URL + path); // https:.... var request = method.Equals("POST") ? new RestRequest(Method.POST) : new RestRequest(Method.GET); request.RequestFormat = RestSharp.DataFormat.Json; // The path to the certificate. string certificate = "cer/cert.cer"; client.ClientCertificates.Add(new X509Certificate(certificate)); request.AddBody( obj ); IRestResponse<User> response = client.Execute<User>(request); return response; } 
+9
c # ssl x509certificate restsharp
source share
1 answer

First you need to import the certificate, and then attach to the request

 X509Certificate2 certificate = new X509Certificate2(); certificates.Import(...); client.ClientCertificates = new X509CertificateCollection(){certificate}; 
+22
source

All Articles