我在Mac上使用Mono 3玩Runscope。使用下面的代码我得到一个例外:
System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: The authentication or decryption has failed.
我不明白为什么,因为ServicePointManager.ServerCertificateValidationCallback
应该有效地批准所有证书。
另请注意,代码在Windows上的Visual Studio下完美运行。
有什么想法吗?
class Program
{
private static Uri url = new Uri("https://api-github-com-[MY_PERSONAL_TOKEN_HERE].runscope.net/");
static void Main(string[] args)
{
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
MakeRequest();
Console.ReadKey ();
}
private static async Task MakeRequest()
{
try
{
var httpClient = new HttpClient();
var response = await httpClient.GetAsync(url);
var body = await response.Content.ReadAsStringAsync();
Console.WriteLine("Body: " + body);
}
catch(Exception ex)
{
Console.WriteLine (ex);
}
}
}