本文整理汇总了C#中System.Net.Http.WebRequestHandler.SetValidator方法的典型用法代码示例。如果您正苦于以下问题:C# WebRequestHandler.SetValidator方法的具体用法?C# WebRequestHandler.SetValidator怎么用?C# WebRequestHandler.SetValidator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.Http.WebRequestHandler
的用法示例。
在下文中一共展示了WebRequestHandler.SetValidator方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Azure_blob_has_MSFT_cert_in_path
public async Task Azure_blob_has_MSFT_cert_in_path()
{
var h = new WebRequestHandler();
h.SetValidator(info =>
!info.HasErrors &&
new AtLeastOneThumbprintInCertChain(msftThumbs).Eval(info));
using (var client = new HttpClient(h))
{
await client.GetAsync("https://webapibook.blob.core.windows.net/");
}
}
示例2: It_is_possible_to_control_revocation_checking
public async Task It_is_possible_to_control_revocation_checking()
{
var h = new WebRequestHandler();
ServicePointManager.CheckCertificateRevocationList = true;
h.SetValidator(info =>
!info.HasErrors &&
info.ChainPolicyUsed(X509RevocationFlag.ExcludeRoot) &&
info.ChainPolicyUsed(X509RevocationMode.Online) &&
new AtLeastOneThumbprintInCertChain(msftThumbs).Eval(info));
using (var client = new HttpClient(h))
{
await client.GetAsync("https://webapibook.blob.core.windows.net/");
}
}
示例3: GitHub_doest_not_have_MSFT_cert_in_path
public void GitHub_doest_not_have_MSFT_cert_in_path()
{
var h = new WebRequestHandler();
h.SetValidator(info =>
!info.HasErrors &&
new AtLeastOneThumbprintInCertChain(msftThumbs).Eval(info));
using (var client = new HttpClient(h))
{
var exc = Assert.Throws<AggregateException>(() => client.GetAsync("https://api.github.com/").Result);
Assert.IsType<HttpRequestException>(exc.InnerExceptions[0]);
}
}