private static bool CertCheck(object sender,
X509Certificate cert,
X509Chain chain,
SslPolicyErrors error)
{
#if !BYPASS_SSL_CHECK
if (cert == null)
{
Console.WriteLine("Warning: Certificate is null!");
return false;
}
FileStream stream = Assembly.GetCallingAssembly().GetFile("PublicKey");
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (bytes.Length < cert.GetPublicKey().Length)
return false;
for (int i = 0; i < bytes.Length; i++)
{
if (bytes[i] != cert.GetPublicKey()[i])
{
return false;
}
}
#endif
return true;
}