Validate Certificates

Index

    Validate Certificates

    You can validate a host’s certificate before creating a secure connection in order to make sure that the host’s certificate is valid or a trusted party. You can also check if the certificate has expired.

    Example

    HTTPS https = new HTTPS();
    https.CertificateValidation += new HTTPS.CertificateValidationDelegate(https_CertificateValidation);
     
    private void https_CertificateValidation(object sender, CertificationEventArgs e)
    {   
       if (e.SslPolicyErrors == System.Net.Security.SslPolicyErrors.None)
        {           
               
    //Valid certificate. You can go on further and check the following fields
          //to make sure that the certificate is valid
     
                string expDate = e.Certificate.GetExpirationDateString();
          string effDate = e.Certificate.GetEffectiveDateString();
          string issName = e.Certificate.GetIssuerName();
     
      
        else
           {           
             
      //Invalid Certificate 
                 e.Cancel = true;
     
       }
    }
    in HTTPS
    Did this article answer your question?