X509Certificate.Equals Metoda
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Porovná dva X509Certificate objekty pro rovnost.
Přetížení
Equals(Object) |
Porovná dva X509Certificate objekty pro rovnost. |
Equals(X509Certificate) |
Porovná dva X509Certificate objekty pro rovnost. |
Equals(Object)
- Zdroj:
- X509Certificate.cs
- Zdroj:
- X509Certificate.cs
- Zdroj:
- X509Certificate.cs
Porovná dva X509Certificate objekty pro rovnost.
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
Objekt X509Certificate , který chcete porovnat s aktuálním objektem.
Návraty
true
pokud je aktuální X509Certificate objekt roven objektu určenému parametrem other
, v opačném případě false
.
- Atributy
Příklady
Následující příklad porovnává dva certifikáty pro rovnost.
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
Poznámky
Dva objekty se považují za stejné, pokud jsou X509Certificate objekty a mají stejné vystavitele a sériové číslo.
Důležité
Metoda Equals
by se neměla používat při porovnávání certifikátů pro účely zabezpečení. Místo toho použijte hodnotu hash RawData vlastnosti nebo Thumbprint vlastnosti.
Platí pro
Equals(X509Certificate)
- Zdroj:
- X509Certificate.cs
- Zdroj:
- X509Certificate.cs
- Zdroj:
- X509Certificate.cs
Porovná dva X509Certificate objekty pro rovnost.
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
Objekt X509Certificate , který chcete porovnat s aktuálním objektem.
Návraty
true
pokud je aktuální X509Certificate objekt roven objektu určenému parametrem other
, v opačném případě false
.
Příklady
Následující příklad porovnává dva certifikáty pro rovnost.
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
Poznámky
Dva X509Certificate objekty se považují za stejné, pokud mají stejné vystavitele a sériové číslo.
Důležité
Metoda Equals
by se neměla používat při porovnávání certifikátů pro účely zabezpečení. Místo toho použijte hodnotu hash RawData vlastnosti nebo Thumbprint vlastnosti.
Platí pro
Váš názor
https://aka.ms/ContentUserFeedback.
Připravujeme: V průběhu roku 2024 budeme postupně vyřazovat problémy z GitHub coby mechanismus zpětné vazby pro obsah a nahrazovat ho novým systémem zpětné vazby. Další informace naleznete v tématu:Odeslat a zobrazit názory pro