5 // Martin Baulig <martin.baulig@xamarin.com>
7 // Copyright (c) 2015 Xamarin, Inc.
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 using System.Security.Cryptography.X509Certificates;
29 namespace Mono.Security.Interface
31 public sealed class MonoTlsSettings
33 public MonoRemoteCertificateValidationCallback RemoteCertificateValidationCallback {
37 public MonoLocalCertificateSelectionCallback ClientCertificateSelectionCallback {
41 public bool CheckCertificateName {
42 get { return checkCertName; }
43 set { checkCertName = value; }
46 public bool CheckCertificateRevocationStatus {
47 get { return checkCertRevocationStatus; }
48 set { checkCertRevocationStatus = value; }
51 public bool UseServicePointManagerCallback {
52 get { return useServicePointManagerCallback; }
53 set { useServicePointManagerCallback = value; }
56 public bool SkipSystemValidators {
57 get { return skipSystemValidators; }
58 set { skipSystemValidators = value; }
61 public bool CallbackNeedsCertificateChain {
62 get { return callbackNeedsChain; }
63 set { callbackNeedsChain = value; }
67 * This is only supported if CertificateValidationHelper.SupportsTrustAnchors is true.
69 public X509CertificateCollection TrustAnchors {
73 public object UserSettings {
78 * If you set this here, then it will override 'ServicePointManager.SecurityProtocol'.
80 public TlsProtocols? EnabledProtocols {
85 bool checkCertName = true;
86 bool checkCertRevocationStatus = false;
87 bool useServicePointManagerCallback = false;
88 bool skipSystemValidators = false;
89 bool callbackNeedsChain = true;
90 ICertificateValidator certificateValidator;
92 public MonoTlsSettings ()
99 * Private APIs - do not use!
101 * This is only public to avoid making our internals visible to System.dll.
105 [Obsolete ("Do not use outside System.dll!")]
106 public ICertificateValidator CertificateValidator {
107 get { return certificateValidator; }
110 [Obsolete ("Do not use outside System.dll!")]
111 public MonoTlsSettings CloneWithValidator (ICertificateValidator validator)
114 this.certificateValidator = validator;
118 var copy = new MonoTlsSettings (this);
119 copy.certificateValidator = validator;
123 MonoTlsSettings (MonoTlsSettings other)
125 RemoteCertificateValidationCallback = other.RemoteCertificateValidationCallback;
126 ClientCertificateSelectionCallback = other.ClientCertificateSelectionCallback;
127 checkCertName = other.checkCertName;
128 checkCertRevocationStatus = other.checkCertRevocationStatus;
129 UseServicePointManagerCallback = other.useServicePointManagerCallback;
130 skipSystemValidators = other.skipSystemValidators;
131 callbackNeedsChain = other.callbackNeedsChain;
132 UserSettings = other.UserSettings;
133 EnabledProtocols = other.EnabledProtocols;
134 TrustAnchors = other.TrustAnchors;