X509Certificate.Equals Method (Object)

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Compares two X509Certificate objects for equality.

Namespace:   System.Security.Cryptography.X509Certificates
Assembly:  mscorlib (in mscorlib.dll)

<ComVisibleAttribute(False)>
Public Overrides Function Equals (
	obj As Object
) As Boolean

Parameters

obj
Type: System.Object

An X509Certificate object to compare to the current object.

Return Value

Type: System.Boolean

true if the current X509Certificate object is equal to the object specified by the other parameter; otherwise, false.

Two objects are considered equal if they are X509Certificate objects and they have the same issuer and serial number.

The following example compares two certificates for equality.

Imports System
Imports System.Security.Cryptography.X509Certificates




Public Class X509


   Public Shared Sub Main()

      ' The path to the certificate.
      Dim Certificate As String = "Certificate.cer"
      Dim OtherCertificate As String = "OtherCertificate.cer"

      ' Load the certificate into an X509Certificate object.
      Dim cert As X509Certificate = X509Certificate.CreateFromCertFile(Certificate)

      ' Load the certificate into an X509Certificate object.
      Dim certTwo As X509Certificate = X509Certificate.CreateFromCertFile(OtherCertificate)

      ' Get the value.
      Dim result As Boolean = cert.Equals(certTwo)

      ' Display the value to the console.
      Console.WriteLine(result)
   End Sub  
End Class 

.NET Framework
Available since 2.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: