共用方式為


X509ServiceCertificateAuthentication.CertificateValidationMode 屬性

定義

取得或設定憑證驗證模式。

public:
 property System::ServiceModel::Security::X509CertificateValidationMode CertificateValidationMode { System::ServiceModel::Security::X509CertificateValidationMode get(); void set(System::ServiceModel::Security::X509CertificateValidationMode value); };
public System.ServiceModel.Security.X509CertificateValidationMode CertificateValidationMode { get; set; }
member this.CertificateValidationMode : System.ServiceModel.Security.X509CertificateValidationMode with get, set
Public Property CertificateValidationMode As X509CertificateValidationMode

屬性值

X509CertificateValidationMode

來自 X509CertificateValidationMode 中列舉的值。

範例

下列程式碼將示範如何設定這個屬性。

ClientCredentials creds = new ClientCredentials();
// Configure peer trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode =
          X509CertificateValidationMode.PeerTrust;

// Configure chain trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode =
              X509CertificateValidationMode.ChainTrust;

// Configure custom certificate validation.
creds.ServiceCertificate.Authentication.CertificateValidationMode =
              X509CertificateValidationMode.Custom;
creds.ServiceCertificate.Authentication.CustomCertificateValidator =
    new MyCertificateValidator();
Dim creds As New ClientCredentials()
' Configure peer trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust

' Configure chain trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.ChainTrust

' Configure custom certificate validation.
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom
creds.ServiceCertificate.Authentication.CustomCertificateValidator = New MyCertificateValidator()

這個屬性也可以在組態檔中設定。

備註

這個列舉型別所擷取的選項,可用來判定使用 SSL/TLS 交涉所取得之服務憑證的有效性。 如需列舉型別成員的清單,請參閱 X509CertificateValidationMode

適用於