Search code examples
certificaterestsharp

How to add a certificate to the last version of restsharp


It seems that in the last version of this library has changed the way of include a certificate on posting a request.

I use the following:

var certFile = "xxxxxxx.pfx";

X509Certificate2 certificate = new X509Certificate2(certFile, "pass");

request.ClientCertificates = new X509CertificateCollection() { certificate };

but in the last version the method "ClientCertificates" does not exist anymore.

Does someone know the way of incluing a certificate now?

Thanks!!


Solution

  • It's in the migration guide

    var options = new RestClientOptions(baseUri) {
        ClientCertificates = ...
    };
    var client = new RestClient(options);