Udostępnij za pośrednictwem


X509Certificate.Equals Metoda

Definicja

Porównuje dwa X509Certificate obiekty pod kątem równości.

Przeciążenia

Equals(Object)

Porównuje dwa X509Certificate obiekty pod kątem równości.

Equals(X509Certificate)

Porównuje dwa X509Certificate obiekty pod kątem równości.

Equals(Object)

Źródło:
X509Certificate.cs
Źródło:
X509Certificate.cs
Źródło:
X509Certificate.cs

Porównuje dwa X509Certificate obiekty pod kątem równości.

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

Parametry

obj
Object

Obiekt X509Certificate do porównania z bieżącym obiektem.

Zwraca

true jeśli bieżący X509Certificate obiekt jest równy obiektowi określonemu other przez parametr ; w przeciwnym razie false.

Atrybuty

Przykłady

Poniższy przykład porównuje dwa certyfikaty pod kątem równości.

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

Uwagi

Dwa obiekty są traktowane jako równe, jeśli są X509Certificate obiektami i mają tego samego wystawcę i numer seryjny.

Ważne

Metoda Equals nie powinna być używana podczas porównywania certyfikatów do celów zabezpieczeń. Zamiast tego należy użyć skrótu RawData właściwości lub Thumbprint właściwości .

Dotyczy

Equals(X509Certificate)

Źródło:
X509Certificate.cs
Źródło:
X509Certificate.cs
Źródło:
X509Certificate.cs

Porównuje dwa X509Certificate obiekty pod kątem równości.

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

Parametry

other
X509Certificate

Obiekt X509Certificate do porównania z bieżącym obiektem.

Zwraca

true jeśli bieżący X509Certificate obiekt jest równy obiektowi określonemu other przez parametr ; w przeciwnym razie false.

Przykłady

Poniższy przykład porównuje dwa certyfikaty pod kątem równości.

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

Uwagi

Dwa X509Certificate obiekty są traktowane jako równe, jeśli mają tego samego wystawcę i numer seryjny.

Ważne

Metoda Equals nie powinna być używana podczas porównywania certyfikatów do celów zabezpieczeń. Zamiast tego należy użyć skrótu RawData właściwości lub Thumbprint właściwości .

Dotyczy