我有一个.crt文件和一个.key文件,必须使用C#在我的rest调用中发送该文件。我到处都找到了将这些文件转换为单个.pfx文件的建议,但问题是服务器不接受pfx。它接受.pem或同时需要.crt和.key文件。我真的可以使用RestSharp发送一个.pem文件和一个get调用吗?我尝试使用以下代码,但响应始终显示“ ACL拒绝连接”。预先感谢您的任何帮助。
`
var client = new RestClient(@"https://midway-itg-stage.glb1.hpe.com/files/storeeasy/");
//ServicePointManager.Expect100Continue = true;
ServicePointManager.DefaultConnectionLimit = 9999;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3;
string certFile = @"C:\test_openssl.pem";
X509Certificate2 certificate = new X509Certificate2(certFile,"file");
client.ClientCertificates = new X509CertificateCollection() { certificate };
//client.Proxy = new WebProxy();
var restrequest = new RestRequest(Method.GET);
//restrequest.AddHeader("Cache-Control", "no-cache");
restrequest.AddHeader("Accept", "application/json");
restrequest.AddHeader("Content-Type", "application/json");
IRestResponse response = client.Execute(restrequest);
Console.WriteLine(JsonConvert.SerializeObject(response));
Console.WriteLine();
Console.WriteLine();
return response.Content;`