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);
76 int Read (byte[] buffer, int offset, int count);
78 void Write (byte[] buffer);
80 void Write (byte[] buffer, int offset, int count);
82 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
84 int EndRead (IAsyncResult asyncResult);
86 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
88 void EndWrite (IAsyncResult asyncResult);
90 Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken);
92 Task ShutdownAsync ();
94 TransportContext TransportContext {
98 bool IsAuthenticated {
102 bool IsMutuallyAuthenticated {
118 SSA.CipherAlgorithmType CipherAlgorithm {
126 SSA.HashAlgorithmType HashAlgorithm {
134 SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
138 int KeyExchangeStrength {
162 void SetLength (long value);
164 AuthenticatedStream AuthenticatedStream {
176 bool CheckCertRevocationStatus {
180 X509Certificate InternalLocalCertificate {
184 X509Certificate LocalCertificate {
188 X509Certificate RemoteCertificate {
192 SSA.SslProtocols SslProtocol {
196 MonoTlsProvider Provider {
201 MonoTlsConnectionInfo GetConnectionInfo ();