Example #1
0
 private void wskClient_ValidateCertificate(object sender, ValidateCertificateEventArgs e)
 {
     /**
      * The exact same event is called on the server as on the client - however the context is different.
      *
      * On the client it is called when attempting to validate the certificate the SERVER SENT.
      */
     e.IsValid = true;
 }
Example #2
0
        /// <summary>
        ///     Display a messagebox with the certificate details, ask user to approve/decline it.
        /// </summary>
        public static void CheckCertificate(object sender, ValidateCertificateEventArgs n)
        {
            // Do we trust the server's certificate?
            var certificateTrustedResult = MessageBox.Show(n.ValidationMessage(), "Do you trust this certificate?", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            var trusted = (certificateTrustedResult == DialogResult.Yes);

            n.IsTrusted = trusted;

            if (trusted)
            {
                Settings.TrustedCertificates.Add(n.Fingerprint);
                Settings.SaveCertificates();
            }
        }
Example #3
0
 private void wskServer_ValidateCertificate(object sender, ValidateCertificateEventArgs e)
 {
     /**
      * Called when attempting to validate a certificate the CLIENT SENT for authentication
      *
      * The default value for IsValid is determined by the SslPolicyErrors as defined in System.Net.Security
      * None: No SSL policy errors.
      * RemoteCertificateNotAvailable: Certificate not available.
      * RemoteCertificateNameMismatch: Certificate name mismatch.
      * RemoteCertificateChainErrors: Problem with the certificate chain.
      *
      * IsValid defaults to TRUE only when SslPolicyErrors = None, otherwise false.
      *
      * This method allows you to define your own checks on the certifcate.
      *
      * You can make a previously invalid certificate valid, by setting IsValid to true or vice versa.
      */
     e.IsValid = true;
 }