RestSharp using ssl certificate

3

I need to use certificate to connect to a https server with restsharp . I'm using this code:

var client = new RestClient(url);
client.ClientCertificates = new X509CertificateCollection();
client.ClientCertificates.Add(GetCertificado());

var request = new RestRequest("authorisationTransaction", Method.POST);
request.AddHeader("Content-type", "application/json; charset=utf-8");
request.AddHeader("Accept", "application/json");
request.RequestFormat = DataFormat.Json;

But I get the message:

  

The underlying connection was closed: Could not establish   trust relationship for the SSL / TLS secure channel.

To read the disk certificate I'm using this method:

    private X509Certificate GetCertificado()
    {
        string Certificate = "certificado.cer";
        X509Certificate cert = new X509Certificate();
        cert.Import(Certificate);
        return cert;
    }

Any ideas how to solve this? Thanks!

    
asked by anonymous 01.05.2015 / 07:21

0 answers