X509Certificate.Equals Método

Definição

Compara dois objetos X509Certificate quanto à igualdade.

Sobrecargas

Equals(Object)

Compara dois objetos X509Certificate quanto à igualdade.

Equals(X509Certificate)

Compara dois objetos X509Certificate quanto à igualdade.

Equals(Object)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Compara dois objetos X509Certificate quanto à igualdade.

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

Um objeto X509Certificate a ser comparado com o objeto atual.

Retornos

true se o objeto atual X509Certificate for igual ao objeto especificado pelo parâmetro other; caso contrário, false.

Atributos

Exemplos

O exemplo a seguir compara dois certificados para igualdade.

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

Comentários

Dois objetos são considerados iguais se forem X509Certificate objetos e tiverem o mesmo emissor e número de série.

Importante

O Equals método não deve ser usado ao comparar certificados para fins de segurança. Em vez disso, use um hash da RawData propriedade ou a Thumbprint propriedade .

Aplica-se a

Equals(X509Certificate)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Compara dois objetos X509Certificate quanto à igualdade.

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

Um objeto X509Certificate a ser comparado com o objeto atual.

Retornos

true se o objeto atual X509Certificate for igual ao objeto especificado pelo parâmetro other; caso contrário, false.

Exemplos

O exemplo a seguir compara dois certificados para igualdade.

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

Comentários

Dois X509Certificate objetos serão considerados iguais se tiverem o mesmo emissor e número de série.

Importante

O Equals método não deve ser usado ao comparar certificados para fins de segurança. Em vez disso, use um hash da RawData propriedade ou a Thumbprint propriedade .

Aplica-se a