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;
29 using EncryptionPolicy = NewSystemSource::System.Net.Security.EncryptionPolicy;
30 using LocalCertificateSelectionCallback = NewSystemSource::System.Net.Security.LocalCertificateSelectionCallback;
31 using RemoteCertificateValidationCallback = NewSystemSource::System.Net.Security.RemoteCertificateValidationCallback;
32 using SslStream = NewSystemSource::System.Net.Security.SslStream;
36 using System.Threading.Tasks;
38 using MSI = Mono.Security.Interface;
40 using XAuthenticatedStream = System.Net.Security.AuthenticatedStream;
41 using System.Security.Cryptography.X509Certificates;
43 namespace Mono.Security.Providers.NewTls
45 public class MonoNewTlsStream : SslStream, MSI.IMonoSslStream
47 MSI.MonoTlsProvider provider;
49 internal MonoNewTlsStream (Stream innerStream, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
50 : this (innerStream, false, provider, settings)
54 internal MonoNewTlsStream (Stream innerStream, bool leaveOpen, MSI.MonoTlsProvider provider, MSI.MonoTlsSettings settings)
55 : base (innerStream, leaveOpen, EncryptionPolicy.RequireEncryption, provider, settings)
57 this.provider = provider;
60 public MSI.MonoTlsProvider Provider {
61 get { return provider; }
64 new public bool IsClosed {
65 get { return base.IsClosed; }
68 public MSI.MonoTlsConnectionInfo GetConnectionInfo ()
70 return GetMonoConnectionInfo ();
73 public Task Shutdown ()
75 return Task.Factory.FromAsync ((state, result) => BeginShutdown (state, result), EndShutdown, null);
78 public Task RequestRenegotiation ()
80 return Task.Factory.FromAsync ((state, result) => BeginRenegotiate (state, result), EndRenegotiate, null);
83 X509Certificate MSI.IMonoSslStream.InternalLocalCertificate {
84 get { return InternalLocalCertificate; }
87 XAuthenticatedStream MSI.IMonoSslStream.AuthenticatedStream {