See Also

CertificateReceivedEventArgs Members  | Dart.PowerTCP.SslSockets Namespace

Requirements

Namespace: Dart.PowerTCP.SslSockets

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Dart.PowerTCP.SslSockets (in Dart.PowerTCP.SslSockets.dll)

Language

Visual Basic

C#

C++

C++/CLI

Show All

See Also Requirements Languages PowerTCP SSL Sockets for .NET

CertificateReceivedEventArgs Class

Dart.PowerTCP.SslSockets Namespace : CertificateReceivedEventArgs Class

Provides data for any event where certificates are received.

For a list of all members of this type, see CertificateReceivedEventArgs members.

Object Model


Inheritance Hierarchy

System.Object
   System.EventArgs
      Dart.PowerTCP.SslSockets.CertificateReceivedEventArgs

Syntax

[Visual Basic]
Public Class CertificateReceivedEventArgs    Inherits EventArgs
[C#]
public class CertificateReceivedEventArgs : EventArgs
[C++]
public __gc class CertificateReceivedEventArgs : public EventArgs
[C++/CLI]
public ref class CertificateReceivedEventArgs : public EventArgs

Remarks

A CertificateReceivedEventArgs object is passed as a parameter to all events that report the receipt of a certificate from the remote server. Use this object to determine if the received certificate is valid. If any portion of the certificate is determined to be invalid (for example, if Certificate.ExpirationDate has passed), the CertificateEventArgs.Accept property will be false, indicating that the certificate will not be accepted. Set Certificate.Accept to true to override this.

If your code causes an exception, it would be returned to the handling event without you seeing it. To preclude such a condition, you should ALWAYS use a try/ catch block around your event-handling code.

Example

The following example demonstrates creating a simple secure client.

[Visual Basic] 

Private Sub CertificateReceived(ByVal sender As Object, ByRef e As CertificateReceivedEventArgs) Handles Tcp1.CertificateReceived
   Dim msg As String = "The certificate was invalid for the following reason(s)" + vbCrLf

   ' Check to see if the certificate is from a trusted root.
   If Not e.TrustedRoot Then
      msg += "This certificate is not from a trusted root" + vbCrLf
   End If

   ' Check to see if the certificate has a valid date.
   If Not e.ValidDate Then
      msg += "This certificate does not have a valid date" + vbCrLf
   End If

   ' Check to see if the certificate has a valid name.
   If Not e.ValidName Then
      msg += "This certificate does not have a valid name" + vbCrLf
   End If

   If msg <> "" Then
      msg += "Would you like to accept this certificate anyway?"
      If MessageBox.Show(msg, "Invalid Cert Received", MessageBoxButtons.YesNo) = DialogResult.Yes Then
         e.Accept = True
      End If
   End If
End Sub

[C#] 


private void CertificateReceived(object sender, CertificateReceivedEventArgs e)
{
  
string msg = "The certificate was invalid for the following reason(s)\n";

  
// Check to see if the certificate is from a trusted root.
  
if(!e.TrustedRoot)
     msg+=
"This certificate is not from a trusted root\n";

  
// Check to see if the certificate has a valid date.
  
if(!e.ValidDate)
     msg+=
"This certificate does not have a valid date\n";

  
// Check to see if the certificate has a valid name.
  
if(!e.ValidName)
     msg+=
"This certificate does not have a valid name\n";

  
if(!e.Accept)
  {
     msg +=
"Would you like to accept this certificate anyway?";
     
if(MessageBox.Show(msg, "Invalid Cert Received", MessageBoxButtons.YesNo) == DialogResult.Yes)
        e.Accept = true;
  }
}
                

Requirements

Namespace: Dart.PowerTCP.SslSockets

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: Dart.PowerTCP.SslSockets (in Dart.PowerTCP.SslSockets.dll)

See Also

CertificateReceivedEventArgs Members  | Dart.PowerTCP.SslSockets Namespace

 

Send comments on this topic.

Documentation version 1.1.2.0.

© 2008 Dart Communications.  All rights reserved.