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
29 using System.Net.Security;
30 using System.Threading;
31 using System.Threading.Tasks;
32 using SSA = System.Security.Authentication;
33 using System.Security.Cryptography.X509Certificates;
34 using System.Security.Principal;
35 using System.Security.Cryptography;
36 using Mono.Net.Security;
38 namespace Mono.Security.Interface
40 public interface IMonoSslStream : IDisposable
46 void AuthenticateAsClient (string targetHost);
48 void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
50 IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
52 IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
54 void EndAuthenticateAsClient (IAsyncResult asyncResult);
56 void AuthenticateAsServer (X509Certificate serverCertificate);
58 void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
60 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
62 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
64 void EndAuthenticateAsServer (IAsyncResult asyncResult);
66 Task AuthenticateAsClientAsync (string targetHost);
68 Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
70 Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
72 Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
74 int Read (byte[] buffer, int offset, int count);
76 void Write (byte[] buffer);
78 void Write (byte[] buffer, int offset, int count);
80 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
82 int EndRead (IAsyncResult asyncResult);
84 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
86 void EndWrite (IAsyncResult asyncResult);
88 Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken);
90 Task ShutdownAsync ();
92 TransportContext TransportContext {
96 bool IsAuthenticated {
100 bool IsMutuallyAuthenticated {
116 SSA.CipherAlgorithmType CipherAlgorithm {
124 SSA.HashAlgorithmType HashAlgorithm {
132 SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
136 int KeyExchangeStrength {
160 void SetLength (long value);
162 AuthenticatedStream AuthenticatedStream {
174 bool CheckCertRevocationStatus {
178 X509Certificate InternalLocalCertificate {
182 X509Certificate LocalCertificate {
186 X509Certificate RemoteCertificate {
190 SSA.SslProtocols SslProtocol {
194 MonoTlsProvider Provider {
199 MonoTlsConnectionInfo GetConnectionInfo ();