I was playing around with the SslPolicyErrors
enum and noticed the following behavior:
SslPolicyErrors error = SslPolicyErrors.RemoteCertificateChainErrors
| SslPolicyErrors.None
| SslPolicyErrors.RemoteCertificateNameMismatch;
Console.WriteLine(error.HasFlag(SslPolicyErrors.None));
Console.WriteLine(error.HasFlag(SslPolicyErrors.RemoteCertificateChainErrors));
Console.WriteLine(error.HasFlag(SslPolicyErrors.RemoteCertificateNameMismatch));
I would expect the first print for the None flag to be false
, but to my surprise all three prints were true
:
True
True
True
So I looked up the source and found this:
[Flags]
public enum SslPolicyErrors
{
None = 0x0,
RemoteCertificateNotAvailable = 0x1,
RemoteCertificateNameMismatch = 0x2,
RemoteCertificateChainErrors = 0x4
}
Which was exactly what I expected initially, but I don't understand how an instance can both have the None flag and at the same time one or more other flags.