Merge pull request #5573 from lateralusX/lateralusX/windows-invalid-socket-error
[mono.git] / mcs / class / Mono.Security / Mono.Security.Interface / IMonoSslStream.cs
1 //
2 // IMonoSslStream.cs
3 //
4 // Author:
5 //       Martin Baulig <martin.baulig@xamarin.com>
6 //
7 // Copyright (c) 2015 Xamarin, Inc.
8 //
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:
15 //
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
18 //
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
25 // THE SOFTWARE.
26 using System;
27 using System.IO;
28 using System.Net;
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;
37
38 namespace Mono.Security.Interface
39 {
40         public interface IMonoSslStream : IDisposable
41         {
42                 SslStream SslStream {
43                         get;
44                 }
45
46                 void AuthenticateAsClient (string targetHost);
47
48                 void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
49
50                 IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
51
52                 IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
53
54                 void EndAuthenticateAsClient (IAsyncResult asyncResult);
55
56                 void AuthenticateAsServer (X509Certificate serverCertificate);
57
58                 void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
59
60                 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
61
62                 IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
63
64                 void EndAuthenticateAsServer (IAsyncResult asyncResult);
65
66                 Task AuthenticateAsClientAsync (string targetHost);
67
68                 Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
69
70                 Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
71
72                 Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SSA.SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
73
74                 int Read (byte[] buffer, int offset, int count);
75
76                 void Write (byte[] buffer);
77
78                 void Write (byte[] buffer, int offset, int count);
79
80                 IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
81
82                 int EndRead (IAsyncResult asyncResult);
83
84                 IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
85
86                 void EndWrite (IAsyncResult asyncResult);
87
88                 Task WriteAsync (byte[] buffer, int offset, int count, CancellationToken cancellationToken);
89
90                 Task ShutdownAsync ();
91
92                 TransportContext TransportContext {
93                         get;
94                 }
95
96                 bool IsAuthenticated {
97                         get;
98                 }
99
100                 bool IsMutuallyAuthenticated {
101                         get;
102                 }
103
104                 bool IsEncrypted {
105                         get;
106                 }
107
108                 bool IsSigned {
109                         get;
110                 }
111
112                 bool IsServer {
113                         get;
114                 }
115
116                 SSA.CipherAlgorithmType CipherAlgorithm {
117                         get;
118                 }
119
120                 int CipherStrength {
121                         get;
122                 }
123
124                 SSA.HashAlgorithmType HashAlgorithm {
125                         get;
126                 }
127
128                 int HashStrength {
129                         get;
130                 }
131
132                 SSA.ExchangeAlgorithmType KeyExchangeAlgorithm {
133                         get;
134                 }
135
136                 int KeyExchangeStrength {
137                         get;
138                 }
139
140                 bool CanRead {
141                         get;
142                 }
143
144                 bool CanTimeout {
145                         get;
146                 }
147
148                 bool CanWrite {
149                         get;
150                 }
151
152                 long Length {
153                         get;
154                 }
155
156                 long Position {
157                         get;
158                 }
159
160                 void SetLength (long value);
161
162                 AuthenticatedStream AuthenticatedStream {
163                         get;
164                 }
165
166                 int ReadTimeout {
167                         get; set;
168                 }
169
170                 int WriteTimeout {
171                         get; set;
172                 }
173
174                 bool CheckCertRevocationStatus {
175                         get;
176                 }
177
178                 X509Certificate InternalLocalCertificate {
179                         get;
180                 }
181
182                 X509Certificate LocalCertificate {
183                         get;
184                 }
185
186                 X509Certificate RemoteCertificate {
187                         get;
188                 }
189
190                 SSA.SslProtocols SslProtocol {
191                         get;
192                 }
193
194                 MonoTlsProvider Provider {
195                         get;
196                 }
197
198
199                 MonoTlsConnectionInfo GetConnectionInfo ();
200         }
201 }
202