X509Certificate.Equals メソッド

定義

2 つの X509Certificate オブジェクトが等しいかどうかを比較します。Compares two X509Certificate objects for equality.

オーバーロード

Equals(Object)

2 つの X509Certificate オブジェクトが等しいかどうかを比較します。Compares two X509Certificate objects for equality.

Equals(X509Certificate)

2 つの X509Certificate オブジェクトが等しいかどうかを比較します。Compares two X509Certificate objects for equality.

Equals(Object)

2 つの X509Certificate オブジェクトが等しいかどうかを比較します。Compares two X509Certificate objects for equality.

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

パラメーター

obj
Object

現在のオブジェクトと比較する X509Certificate オブジェクト。An X509Certificate object to compare to the current object.

戻り値

現在の X509Certificate オブジェクトが other パラメーターで指定されたオブジェクトと等しい場合は true。それ以外の場合は falsetrue if the current X509Certificate object is equal to the object specified by the other parameter; otherwise, false.

属性

次の例では、2つの証明書が等しいかどうかを比較します。The following example compares two certificates for equality.

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 

注釈

2つのオブジェクトが X509Certificate オブジェクトで、発行者とシリアル番号が同じである場合は、等しいと見なされます。Two objects are considered equal if they are X509Certificate objects and they have the same issuer and serial number.

重要

セキュリティのために証明書を比較する場合は、Equals 方法を使用しないでください。The Equals method should not be used when comparing certificates for security purposes. 代わりに、RawData プロパティのハッシュまたは Thumbprint プロパティを使用します。Instead, use a hash of the RawData property, or the Thumbprint property.

Equals(X509Certificate)

2 つの X509Certificate オブジェクトが等しいかどうかを比較します。Compares two X509Certificate objects for equality.

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

パラメーター

other
X509Certificate

現在のオブジェクトと比較する X509Certificate オブジェクト。An X509Certificate object to compare to the current object.

戻り値

現在の X509Certificate オブジェクトが other パラメーターで指定されたオブジェクトと等しい場合は true。それ以外の場合は falsetrue if the current X509Certificate object is equal to the object specified by the other parameter; otherwise, false.

次の例では、2つの証明書が等しいかどうかを比較します。The following example compares two certificates for equality.

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 

注釈

同じ発行者とシリアル番号がある場合、2つの X509Certificate オブジェクトは等しいと見なされます。Two X509Certificate objects are considered equal if they have the same issuer and serial number.

重要

セキュリティのために証明書を比較する場合は、Equals 方法を使用しないでください。The Equals method should not be used when comparing certificates for security purposes. 代わりに、RawData プロパティのハッシュまたは Thumbprint プロパティを使用します。Instead, use a hash of the RawData property, or the Thumbprint property.

適用対象