Lire en anglais Modifier

Partager via


X509CertificateValidationMode Enum

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

An enumeration that lists the ways of validating a certificate.

C#
public enum X509CertificateValidationMode
Inheritance
X509CertificateValidationMode

Fields

Name Value Description
None 0

No validation of the certificate is done.

PeerTrust 1

The certificate is valid if it is in the trusted people store.

ChainTrust 2

The certificate is valid if the chain builds to a certification authority in the trusted root store.

PeerOrChainTrust 3

The certificate is valid if it is in the trusted people store, or if the chain builds to a certification authority in the trusted root store.

Custom 4

The user must plug in a custom X509CertificateValidator to validate the certificate.

Examples

C#
          ChannelFactory<ISimpleChannel> cf =
              new ChannelFactory<ISimpleChannel>();
          cf.Credentials.ClientCertificate.SetCertificate(
              StoreLocation.CurrentUser, StoreName.My,
              X509FindType.FindByThumbprint,
"37 28 05 09 22 81 07 08 a0 cd 2a af dd c3 83 cd c3 3b 8f 9d");
          cf.Credentials.ServiceCertificate.SetDefaultCertificate(
              StoreLocation.CurrentUser,
              StoreName.TrustedPeople,
              X509FindType.FindByThumbprint,
"33 93 68 cc 7c 75 80 24 a2 80 9f 45 8c 81 fa 92 ad 5b 04 39");
          cf.Credentials.ServiceCertificate.Authentication.CertificateValidationMode
              = X509CertificateValidationMode.PeerOrChainTrust;

Applies to

Produit Versions
.NET Core 1.0, Core 1.1, 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)