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 extern alias NewSystemSource;
32 using System.Net.Security;
33 using System.Security.Authentication;
35 using MSI = Mono.Security.Interface;
36 using MX = Mono.Security.X509;
38 using PSSCX = System.Security.Cryptography.X509Certificates;
39 using SSCX = System.Security.Cryptography.X509Certificates;
41 namespace Mono.Security.Providers.NewTls
43 public class NewTlsProvider : MSI.MonoTlsProvider
45 static readonly Guid id = new Guid ("e5ff34f1-8b7a-4aa6-aff9-24719d709693");
47 public override Guid ID {
51 public override string Name {
52 get { return "newtls"; }
55 public override bool SupportsSslStream {
59 public override bool SupportsConnectionInfo {
63 public override bool SupportsMonoExtensions {
67 internal override bool SupportsTlsContext {
71 public override SslProtocols SupportedProtocols {
72 get { return SslProtocols.Tls12 | SslProtocols.Tls11 | SslProtocols.Tls; }
75 public override MSI.IMonoSslStream CreateSslStream (
76 Stream innerStream, bool leaveInnerStreamOpen,
77 MSI.MonoTlsSettings settings = null)
79 return MonoNewTlsStreamFactory.CreateSslStream (innerStream, leaveInnerStreamOpen, this, settings);
82 internal override MSI.IMonoTlsContext CreateTlsContext (
83 string hostname, bool serverMode, MSI.TlsProtocols protocolFlags,
84 SSCX.X509Certificate serverCertificate, PSSCX.X509CertificateCollection clientCertificates,
85 bool remoteCertRequired, MSI.MonoEncryptionPolicy encryptionPolicy,
86 MSI.MonoTlsSettings settings)
88 var config = TlsProviderFactory.CreateTlsConfiguration (
89 hostname, serverMode, protocolFlags, serverCertificate,
90 remoteCertRequired, settings);
91 return new TlsContextWrapper (config, serverMode);