X509Certificate.Equals Método

Definición

Compara dos objetos X509Certificate para determinar si son iguales.

Sobrecargas

Equals(Object)

Compara dos objetos X509Certificate para determinar si son iguales.

Equals(X509Certificate)

Compara dos objetos X509Certificate para determinar si son iguales.

Equals(Object)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

Compara dos objetos X509Certificate para determinar si son iguales.

public:
 override bool Equals(System::Object ^ obj);
public override bool Equals (object? obj);
public override bool Equals (object obj);
[System.Runtime.InteropServices.ComVisible(false)]
public override bool Equals (object obj);
override this.Equals : obj -> bool
[<System.Runtime.InteropServices.ComVisible(false)>]
override this.Equals : obj -> bool
Public Overrides Function Equals (obj As Object) As Boolean

Parámetros

obj
Object

Objeto X509Certificate que se va a comparar con el objeto actual.

Devoluciones

Es true si el objeto X509Certificate actual es igual al objeto especificado por el parámetro other; en caso contrario, es false.

Atributos

Ejemplos

En el ejemplo siguiente se comparan dos certificados para comprobar si son iguales.

using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   
   // The path to the certificate.
   String^ Certificate = "Certificate.cer";
   String^ OtherCertificate = "OtherCertificate.cer";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ certTwo = X509Certificate::CreateFromCertFile( OtherCertificate );
   
   // Get the value.
   bool result = cert->Equals( certTwo );
   
   // Display the value to the console.
   Console::WriteLine( result );
}

using System;
using System.Security.Cryptography.X509Certificates;

public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate =  "Certificate.cer";
        string OtherCertificate =  "OtherCertificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

        // Load the certificate into an X509Certificate object.
        X509Certificate certTwo = X509Certificate.CreateFromCertFile(OtherCertificate);

        // Get the value.
        bool result = cert.Equals(certTwo);

        // Display the value to the console.
        Console.WriteLine(result);
    }
}
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

Comentarios

Dos objetos se consideran iguales si son X509Certificate objetos y tienen el mismo emisor y número de serie.

Importante

El Equals método no se debe usar al comparar certificados con fines de seguridad. En su lugar, use un hash de la RawData propiedad o la Thumbprint propiedad .

Se aplica a

Equals(X509Certificate)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

Compara dos objetos X509Certificate para determinar si son iguales.

public:
 virtual bool Equals(System::Security::Cryptography::X509Certificates::X509Certificate ^ other);
public virtual bool Equals (System.Security.Cryptography.X509Certificates.X509Certificate? other);
public virtual bool Equals (System.Security.Cryptography.X509Certificates.X509Certificate other);
override this.Equals : System.Security.Cryptography.X509Certificates.X509Certificate -> bool
Public Overridable Function Equals (other As X509Certificate) As Boolean

Parámetros

other
X509Certificate

Objeto X509Certificate que se va a comparar con el objeto actual.

Devoluciones

Es true si el objeto X509Certificate actual es igual al objeto especificado por el parámetro other; en caso contrario, es false.

Ejemplos

En el ejemplo siguiente se comparan dos certificados para comprobar si son iguales.

using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   
   // The path to the certificate.
   String^ Certificate = "Certificate.cer";
   String^ OtherCertificate = "OtherCertificate.cer";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ certTwo = X509Certificate::CreateFromCertFile( OtherCertificate );
   
   // Get the value.
   bool result = cert->Equals( certTwo );
   
   // Display the value to the console.
   Console::WriteLine( result );
}

using System;
using System.Security.Cryptography.X509Certificates;

public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate =  "Certificate.cer";
        string OtherCertificate =  "OtherCertificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

        // Load the certificate into an X509Certificate object.
        X509Certificate certTwo = X509Certificate.CreateFromCertFile(OtherCertificate);

        // Get the value.
        bool result = cert.Equals(certTwo);

        // Display the value to the console.
        Console.WriteLine(result);
    }
}
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

Comentarios

Dos X509Certificate objetos se consideran iguales si tienen el mismo emisor y número de serie.

Importante

El Equals método no se debe usar al comparar certificados con fines de seguridad. En su lugar, use un hash de la RawData propiedad o la Thumbprint propiedad .

Se aplica a