/
X509CertificateValidationMode.cs
61 lines (52 loc) · 2.13 KB
/
X509CertificateValidationMode.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
namespace System.ServiceModel.Security
{
/// <summary>
/// An enumeration that lists the ways of validating a certificate.
/// </summary>
public enum X509CertificateValidationMode
{
/// <summary>
/// No validation of the certificate is performed.
/// </summary>
None,
/// <summary>
/// The certificate is valid if it is in the trusted people store.
/// </summary>
PeerTrust,
/// <summary>
/// The certificate is valid if the chain builds to a certification authority in the trusted root store.
/// </summary>
ChainTrust,
/// <summary>
/// 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.
/// </summary>
PeerOrChainTrust,
/// <summary>
/// The user must plug in a custom <c>X509CertificateValidator</c> to validate the certificate.
/// </summary>
Custom
}
internal static class X509CertificateValidationModeHelper
{
public static bool IsDefined(X509CertificateValidationMode validationMode)
{
return validationMode == X509CertificateValidationMode.None
|| validationMode == X509CertificateValidationMode.PeerTrust
|| validationMode == X509CertificateValidationMode.ChainTrust
|| validationMode == X509CertificateValidationMode.PeerOrChainTrust
|| validationMode == X509CertificateValidationMode.Custom;
}
internal static void Validate(X509CertificateValidationMode value)
{
if (!IsDefined(value))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidEnumArgumentException("value", (int)value,
typeof(X509CertificateValidationMode)));
}
}
}
}