如何在Simple.OData.Client中进行证书认证?我有调用api时想使用的X509Certificate2。我使用.net框架4.6。如何在Simple.OData.Client中使用证书身份验证?
我做了一些搜索,我知道可以通过HttpClientHandler添加。但我无法弄清楚如何做到这一点。以下是我的代码。
void foo()
{
var clientSettings = new ODataClientSettings("");
clientSettings.OnApplyClientHandler = new Action<HttpClientHandler>(AddClientCertificate);
var client = new ODataClient(clientSettings);
}
private void AddClientCertificate(HttpClientHandler handler)
{
// I have working code to retrieve the certificate.
X509Certificate2 targetCertificate = RetrieveCertificate();
//TODO : Add the certificate to the HttpClientHandler
}