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 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 abstract class MonoSslStream : IDisposable
41 public abstract void AuthenticateAsClient (string targetHost);
43 public abstract void AuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
45 public abstract IAsyncResult BeginAuthenticateAsClient (string targetHost, AsyncCallback asyncCallback, object asyncState);
47 public abstract IAsyncResult BeginAuthenticateAsClient (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
49 public abstract void EndAuthenticateAsClient (IAsyncResult asyncResult);
51 public abstract void AuthenticateAsServer (X509Certificate serverCertificate);
53 public abstract void AuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
55 public abstract IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, AsyncCallback asyncCallback, object asyncState);
57 public abstract IAsyncResult BeginAuthenticateAsServer (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation, AsyncCallback asyncCallback, object asyncState);
59 public abstract void EndAuthenticateAsServer (IAsyncResult asyncResult);
61 public abstract Task AuthenticateAsClientAsync (string targetHost);
63 public abstract Task AuthenticateAsClientAsync (string targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
65 public abstract Task AuthenticateAsServerAsync (X509Certificate serverCertificate);
67 public abstract Task AuthenticateAsServerAsync (X509Certificate serverCertificate, bool clientCertificateRequired, SslProtocols enabledSslProtocols, bool checkCertificateRevocation);
69 public abstract void Flush ();
71 public abstract int Read (byte[] buffer, int offset, int count);
73 public abstract void Write (byte[] buffer);
75 public abstract void Write (byte[] buffer, int offset, int count);
77 public abstract IAsyncResult BeginRead (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
79 public abstract int EndRead (IAsyncResult asyncResult);
81 public abstract IAsyncResult BeginWrite (byte[] buffer, int offset, int count, AsyncCallback asyncCallback, object asyncState);
83 public abstract void EndWrite (IAsyncResult asyncResult);
85 public abstract TransportContext TransportContext {
89 public abstract bool IsAuthenticated {
93 public abstract bool IsMutuallyAuthenticated {
97 public abstract bool IsEncrypted {
101 public abstract bool IsSigned {
105 public abstract bool IsServer {
109 public abstract CipherAlgorithmType CipherAlgorithm {
113 public abstract int CipherStrength {
117 public abstract HashAlgorithmType HashAlgorithm {
121 public abstract int HashStrength {
125 public abstract ExchangeAlgorithmType KeyExchangeAlgorithm {
129 public abstract int KeyExchangeStrength {
133 public abstract bool CanRead {
137 public abstract bool CanTimeout {
141 public abstract bool CanWrite {
145 public abstract long Length {
149 public abstract long Position {
153 public abstract void SetLength (long value);
155 public abstract AuthenticatedStream AuthenticatedStream {
159 public abstract int ReadTimeout {
163 public abstract int WriteTimeout {
167 public abstract bool CheckCertRevocationStatus {
171 public abstract X509Certificate InternalLocalCertificate {
175 public abstract X509Certificate LocalCertificate {
179 public abstract X509Certificate RemoteCertificate {
183 public abstract SslProtocols SslProtocol {
187 public void Dispose ()
190 GC.SuppressFinalize (this);
193 protected virtual void Dispose (bool disposing)