Ich habe den folgenden Code:Mono vs. NET - Unterschied in der Serverzertifikatsprüfung?
class MainClass
{
public static void Main (string[] args)
{
ServicePointManager.ServerCertificateValidationCallback += ServerCertificateValidationCallback;
HttpWebRequest.CreateHttp("https://www.badssl.com/").GetResponse();
HttpWebRequest.CreateHttp("https://wrong.host.badssl.com/").GetResponse();
Console.ReadLine();
}
private static bool ServerCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
Console.WriteLine(((HttpWebRequest) sender).RequestUri + " " + sslPolicyErrors);
return true;
}
}
Ich laufe es auf Windows 8 und Mac OSX.
Mac OS X
https://www.badssl.com/ None
https://www.badssl.com/ None
https://wrong.host.badssl.com/ RemoteCertificateChainErrors
Fenster (.net 4.5):
https://www.badssl.com/ None
https://www.badssl.com/ None
https://wrong.host.badssl.com/ RemoteCertificateNameMismatch
Jede Idee, warum ich unterschiedliche Ergebnisse erhalten? Ich würde gerne RemoteCertificateNameMismatch
auf dem Mac OS X Fall haben, da ich denke, dass es korrekt ist.
Haben Sie versucht, es auf Mono unter Windows laufen zu lassen? Könnte ein Schuss wert sein –
Ich würde durch die Mono-Quelle scrollen, wie es scheint, dass sie native OS-X-Funktionen verwenden, um das Cert-Problem abzuleiten ... 'EvaluateSystem'' CheckUsage' etc ... 'https://github.com /mono/mono/blob/5a701f39c7d914c5a04da2d33f806b0709b67a5a/mcs/class/System/Mono.Net.Security/SystemCertificateValidator.cs – SushiHangover
Getestet auf Mono unter Windows und da bekomme ich RemoteCertificateNameMismatch. –