如何在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
}