X509Certificate.Equals 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
比较两个 X509Certificate 对象是否相等。
重载
Equals(Object) |
比较两个 X509Certificate 对象是否相等。 |
Equals(X509Certificate) |
比较两个 X509Certificate 对象是否相等。 |
Equals(Object)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
比较两个 X509Certificate 对象是否相等。
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
参数
- obj
- Object
要与当前对象进行比较的 X509Certificate 对象。
返回
如果当前 X509Certificate 对象等于 other
参数指定的对象,则为 true
;否则为 false
。
- 属性
示例
以下示例比较两个证书是否相等。
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
注解
如果两个对象是 X509Certificate 对象,并且它们具有相同的颁发者和序列号,则它们被视为相等。
重要
Equals
出于安全目的比较证书时,不应使用 方法。 请改用 属性或 属性的RawDataThumbprint哈希。
适用于
Equals(X509Certificate)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
比较两个 X509Certificate 对象是否相等。
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
参数
- other
- X509Certificate
要与当前对象进行比较的 X509Certificate 对象。
返回
如果当前 X509Certificate 对象等于 other
参数指定的对象,则为 true
;否则为 false
。
示例
以下示例比较两个证书是否相等。
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
注解
如果两个 X509Certificate 对象具有相同的颁发者和序列号,则它们被视为相等。
重要
Equals
出于安全目的比较证书时,不应使用 方法。 请改用 属性或 属性的RawDataThumbprint哈希。