tango.net.SSLServerSocket

License:

BSD style: see license.txt

Author:

Jeff Davey
class SSLServerSocket : ServerSocket #
SSLServerSocket is a sub-class of ServerSocket. It's purpose is to provide SSL encryption at the socket level as well as easily tie into existing Tango applications that may already be using ServerSocket.
SSLServerSocket requires the OpenSSL library, and uses a dynamic binding to the library. You can find the library at http://www.openssl.org and a Win32 specific port at http://www.slproweb.com/products/Win32OpenSSL.html.

Example

1
2
3
4
5
6
7
8
9
10
11
12
auto cert = new Certificate(cast(char[])File("public.pem").read);
auto pkey = new PrivateKey(cast(char[])File("private.pem").read);
auto ctx = new SSLCtx();
ctx.certificate(cert).privateKey(pkey);
auto server = new SSLServerSocket(new InternetAddress(443), ctx);
for(;;)
{
    auto sslSock = server.accept();
    sc.write("HTTP/1.1 200\r\n\r\n<b>Hello World</b>");
    sc.shutdown();
    sc.close();
}
this(InternetAddress addr, SSLCtx ctx, int backlog = 32, bool reuse = false) #
Constructs a new SSLServerSocket. This constructor is similar to ServerSocket, except it takes a SSLCtx as provided by PKI.

Params:

addrthe address to bind and listen on.
ctxthe provided SSLCtx
backlogthe number of connections to backlog before refusing connection
reuseif enabled, allow rebinding of existing ip/port
SSLSocketConduit create() [override] #
This is used during the super.accept() in order to provide the proper SSLSocketConduit. It allocates using the free-list provided with SSLSocketConduit.
SSLSocketConduit accept() #
Accepts a new conection and copies the provided server SSLCtx to a new SSLSocketConduit.