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 static readonly Guid id = new Guid ("809e77d5-56cc-4da8-b9f0-45e65ba9cceb");
53 public override Guid ID {
57 public override string Name {
58 get { return "legacy"; }
61 public override bool SupportsSslStream {
65 public override bool SupportsConnectionInfo {
69 public override bool SupportsMonoExtensions {
73 public override SslProtocols SupportedProtocols {
74 get { return SslProtocols.Tls; }
77 public override MSI.IMonoSslStream CreateSslStream (
78 Stream innerStream, bool leaveInnerStreamOpen,
79 MSI.MonoTlsSettings settings = null)
81 var impl = new Private.LegacySslStream (innerStream, leaveInnerStreamOpen, this, settings);
82 return new Private.MonoSslStreamImpl (impl);
85 internal override bool ValidateCertificate (
86 MSI.ICertificateValidator2 validator, string targetHost, bool serverMode,
87 X509CertificateCollection certificates, bool wantsChain, ref X509Chain chain,
88 ref MSI.MonoSslPolicyErrors errors, ref int status11)
91 chain = SystemCertificateValidator.CreateX509Chain (certificates);
92 var xerrors = (SslPolicyErrors)errors;
93 var result = SystemCertificateValidator.Evaluate (validator.Settings, targetHost, certificates, chain, ref xerrors, ref status11);
94 errors = (MSI.MonoSslPolicyErrors)xerrors;