System.Security.Cryptography.X509Certificates.X509Certificate.GetCertHash C# (CSharp) Method

GetCertHash() public method

public GetCertHash ( ) : byte[]
return byte[]
        public virtual byte[] GetCertHash()
        {
            ThrowIfInvalid();
            return GetRawCertHash().CloneByteArray();
        }

Usage Example

示例#1
0
        private static bool ValidateServerCertficate(
                object sender,
                X509Certificate cert,
                X509Chain chain,
                SslPolicyErrors sslPolicyErrors)
        {
            if (sslPolicyErrors == SslPolicyErrors.None)
            {
                return true;
            }

            bool certMatch = false;
            byte[] certHash = cert.GetCertHash();
            if (certHash.Length == ApiCertHash.Length)
            {
                certMatch = true; 
                for (int idx = 0; idx < certHash.Length; idx++)
                {
                    if (certHash[idx] != ApiCertHash[idx])
                    {
                        certMatch = false; 
                        break;
                    }
                }
            }
            
            return certMatch;
        }
All Usage Examples Of System.Security.Cryptography.X509Certificates.X509Certificate::GetCertHash