forked from bonesoul/uhttpsharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientSslDecoerator.cs
More file actions
41 lines (35 loc) · 978 Bytes
/
Copy pathClientSslDecoerator.cs
File metadata and controls
41 lines (35 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.IO;
using System.Net;
using System.Net.Security;
using System.Security.Authentication;
using System.Security.Cryptography.X509Certificates;
namespace uhttpsharp.Clients
{
public class ClientSslDecorator : IClient
{
private readonly IClient _child;
private readonly SslStream _sslStream;
public ClientSslDecorator(IClient child, X509Certificate certificate)
{
_child = child;
_sslStream = new SslStream(_child.Stream);
_sslStream.AuthenticateAsServer(certificate, false, SslProtocols.Tls, true);
}
public Stream Stream
{
get { return _sslStream; }
}
public bool Connected
{
get { return _child.Connected; }
}
public void Close()
{
_child.Close();
}
public EndPoint RemoteEndPoint
{
get { return _child.RemoteEndPoint; }
}
}
}