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
41 void AuthenticateAsClient (string targetHost);
43 void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
45 IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
47 IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
49 void EndAuthenticateAsClient (IAsyncResult asyncResult);
51 void AuthenticateAsServer (X509Certificate serverCertificate);
53 void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
55 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
57 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
59 void EndAuthenticateAsServer (IAsyncResult asyncResult);
61 Task AuthenticateAsClientAsync (string targetHost);
63 Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
65 Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
67 Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
71 int Read (byte[] buffer, int offset, int count);
73 void Write (byte[] buffer);
75 void Write (byte[] buffer, int offset, int count);
77 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
79 int EndRead (IAsyncResult asyncResult);
81 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
83 void EndWrite (IAsyncResult asyncResult);
85 TransportContext TransportContext {
89 bool IsAuthenticated {
93 bool IsMutuallyAuthenticated {
109 SSA.CipherAlgorithmType CipherAlgorithm {
117 SSA.HashAlgorithmType HashAlgorithm {
125 SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
129 int KeyExchangeStrength {
153 void SetLength (long value);
155 AuthenticatedStream AuthenticatedStream {
167 bool CheckCertRevocationStatus {
171 X509Certificate InternalLocalCertificate {
175 X509Certificate LocalCertificate {
179 X509Certificate RemoteCertificate {
183 SSA.SslProtocols SslProtocol {