简体   繁体   English

从TLS 1.2仅端点请求时的HttpClient异常

[英]HttpClient Exception When Requesting from a TLS 1.2 Only Endpoint

Does anyone know how to get HttpClient to work with a site that only supports TLS 1.2. 有谁知道如何让HttpClient与仅支持TLS 1.2的站点一起使用。 I've verified with SSL Labs, https://www.ssllabs.com/ssltest/analyze.html?d=sandbox.paypal.com , that paypal has turned off all but TLS 1.2 on their sandbox site. 我已经通过SSL实验室https://www.ssllabs.com/ssltest/analyze.html?d=sandbox.paypal.com进行了验证,贝宝已关闭其沙盒网站上除TLS 1.2之外的所有功能。

When I run the following code, I get an exception with the message, "The remote certificate is invalid according to the validation procedure." 当我运行以下代码时,出现异常消息:“根据验证过程,远程证书无效。”

var client = new HttpClient();
var content = client
    .GetAsync("https://sandbox.paypal.com/")
    .Result;

Their certificate is valid for www.sanbox.paypal.com but not for sandbox.paypal.com . 他们的证书仅对www.sanbox.paypal.com有效,而对sandbox.paypal.com无效。 Either add 'www' to the request URI or use custom certificate validation callback, like: 将“ www”添加到请求URI或使用自定义证书验证回调,例如:

ServicePointManager.ServerCertificateValidationCallback =
    (sender, cert, chain, sslPolicyErrors) => true;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM