2 // LegacyTlsProvider.cs
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 #if MONO_SECURITY_ALIAS
28 extern alias MonoSecurity;
31 #if MONO_SECURITY_ALIAS
32 using MSI = MonoSecurity::Mono.Security.Interface;
34 using MSI = Mono.Security.Interface;
40 using System.Net.Security;
41 using System.Security.Cryptography.X509Certificates;
42 using System.Security.Authentication;
44 namespace Mono.Net.Security
47 * Strictly private - do not use outside the Mono.Net.Security directory.
49 class LegacyTlsProvider : MSI.MonoTlsProvider
51 public override Guid ID {
52 get { return MonoTlsProviderFactory.LegacyId; }
55 public override string Name {
56 get { return "legacy"; }
59 public override bool SupportsSslStream {
63 public override bool SupportsConnectionInfo {
67 public override bool SupportsMonoExtensions {
71 public override SslProtocols SupportedProtocols {
72 get { return SslProtocols.Tls; }
75 public override MSI.IMonoSslStream CreateSslStream (
76 Stream innerStream, bool leaveInnerStreamOpen,
77 MSI.MonoTlsSettings settings = null)
79 return SslStream.CreateMonoSslStream (innerStream, leaveInnerStreamOpen, this, settings);
82 internal override MSI.IMonoSslStream CreateSslStreamInternal (
83 SslStream sslStream, Stream innerStream, bool leaveInnerStreamOpen,
84 MSI.MonoTlsSettings settings)
86 return new Private.LegacySslStream (innerStream, leaveInnerStreamOpen, sslStream, this, settings);
89 internal override bool ValidateCertificate (
90 MSI.ICertificateValidator2 validator, string targetHost, bool serverMode,
91 X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain,
92 ref MSI.MonoSslPolicyErrors errors, ref int status11)
95 chain = SystemCertificateValidator.CreateX509Chain (certificates);
96 var xerrors = (SslPolicyErrors)errors;
97 var result = SystemCertificateValidator.Evaluate (validator.Settings, targetHost, certificates, chain, ref xerrors, ref status11);
98 errors = (MSI.MonoSslPolicyErrors)xerrors;