X509Certificate.Equals Metode
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Membandingkan dua X509Certificate objek untuk kesetaraan.
Overload
Equals(Object) |
Membandingkan dua X509Certificate objek untuk kesetaraan. |
Equals(X509Certificate) |
Membandingkan dua X509Certificate objek untuk kesetaraan. |
Equals(Object)
- Sumber:
- X509Certificate.cs
- Sumber:
- X509Certificate.cs
- Sumber:
- X509Certificate.cs
Membandingkan dua X509Certificate objek untuk kesetaraan.
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
Parameter
- obj
- Object
Objek X509Certificate untuk dibandingkan dengan objek saat ini.
Mengembalikan
true
jika objek saat ini X509Certificate sama dengan objek yang ditentukan oleh other
parameter; jika tidak, false
.
- Atribut
Contoh
Contoh berikut membandingkan dua sertifikat untuk kesetaraan.
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
Keterangan
Dua objek dianggap sama jika objeknya adalah X509Certificate objek dan mereka memiliki penerbit dan nomor seri yang sama.
Penting
Metode Equals
ini tidak boleh digunakan saat membandingkan sertifikat untuk tujuan keamanan. Sebagai gantinya RawData , gunakan hash properti , atau Thumbprint properti .
Berlaku untuk
Equals(X509Certificate)
- Sumber:
- X509Certificate.cs
- Sumber:
- X509Certificate.cs
- Sumber:
- X509Certificate.cs
Membandingkan dua X509Certificate objek untuk kesetaraan.
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
Parameter
- other
- X509Certificate
Objek X509Certificate untuk dibandingkan dengan objek saat ini.
Mengembalikan
true
jika objek saat ini X509Certificate sama dengan objek yang ditentukan oleh other
parameter; jika tidak, false
.
Contoh
Contoh berikut membandingkan dua sertifikat untuk kesetaraan.
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
Keterangan
Dua X509Certificate objek dianggap sama jika memiliki pengeluar sertifikat dan nomor seri yang sama.
Penting
Metode Equals
ini tidak boleh digunakan saat membandingkan sertifikat untuk tujuan keamanan. Sebagai gantinya RawData , gunakan hash properti , atau Thumbprint properti .