我有以下curl请求,其中包含客户端证书,密钥和cacert
WHERE a.screen_id=384
AND a.timestamp BETWEEN 1462670000000 AND 1463374800000
GROUP BY a.answer_id
我希望能够将其转换为C#,但我正在努力让它与--cacert一起工作。我有以下代码来创建我的HttpClient并发出http请求
curl https://insert_url_here --key transport.key --cert transport.pem --cacert ca.cer
注意:我已将transport.key / transport.pem合并到transport.pfx中。
我正在努力验证cacert,curl请求可以正常运行,但我收到.net public async Task MakeHttpRequest()
{
using (var httpClient = CreateClient())
{
var response = await httpClient.GetAsync("https://insert_url_here");
}
}
public HttpClient CreateClient()
{
var handler = new HttpClientHandler();
handler.ClientCertificates.Add(TRANSPORT_CERT);
handler.ServerCertificateCustomValidationCallback = (req, cert, chain, err) =>
{
// should i check the ca here?!
return true;
};
return new HttpClient(handler);
}
中的证书错误。我无法将cacert放在受信任的商店中,所以如何在我的RemoteCertificateChainErrors
中不进行验证? X509Chain?如果是这样的话......