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.Tasks;
31 using SSA = System.Security.Authentication;
32 using System.Security.Cryptography.X509Certificates;
33 using System.Security.Principal;
34 using System.Security.Cryptography;
35 using Mono.Net.Security;
37 namespace Mono.Security.Interface
39 public interface IMonoSslStream : IDisposable
45 void AuthenticateAsClient (string targetHost);
47 void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
49 IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
51 IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
53 void EndAuthenticateAsClient (IAsyncResult asyncResult);
55 void AuthenticateAsServer (X509Certificate serverCertificate);
57 void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
59 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
61 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
63 void EndAuthenticateAsServer (IAsyncResult asyncResult);
65 Task AuthenticateAsClientAsync (string targetHost);
67 Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
69 Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
71 Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
75 int Read (byte[] buffer, int offset, int count);
77 void Write (byte[] buffer);
79 void Write (byte[] buffer, int offset, int count);
81 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
83 int EndRead (IAsyncResult asyncResult);
85 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
87 void EndWrite (IAsyncResult asyncResult);
89 Task ShutdownAsync ();
91 TransportContext TransportContext {
95 bool IsAuthenticated {
99 bool IsMutuallyAuthenticated {
115 SSA.CipherAlgorithmType CipherAlgorithm {
123 SSA.HashAlgorithmType HashAlgorithm {
131 SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
135 int KeyExchangeStrength {
159 void SetLength (long value);
161 AuthenticatedStream AuthenticatedStream {
173 bool CheckCertRevocationStatus {
177 X509Certificate InternalLocalCertificate {
181 X509Certificate LocalCertificate {
185 X509Certificate RemoteCertificate {
189 SSA.SslProtocols SslProtocol {
193 MonoTlsProvider Provider {
198 MonoTlsConnectionInfo GetConnectionInfo ();