auto s = new SSLSocket;
if (s.connect("www.yahoo.com", 443))
{
char[1024] buff;
s.write("GET / HTTP/1.0\r\n\r\n");
auto bytesRead = s.read(buff);
if (bytesRead != s.Eof)
Stdout.formatln("received: {}", buff[0..bytesRead]);
}
| SSLCtx ctx | SSLCtx class as provided by PKI |
| bool clientMode | if true, the socket will be in Client Mode, Server otherwise. |
auto cert = new Certificate(cast(char[])File.get("public.pem"));
auto pkey = new PrivateKey(cast(char[])File.get("private.pem"));
auto ctx = new SSLCtx;
ctx.certificate(cert).privateKey(pkey);
auto server = new SSLServerSocket(443, ctx);
for(;;)
{
auto sc = server.accept;
sc.write("HTTP/1.1 200\r\n\r\n<b>Hello World</b>");
sc.shutdown.close;
}
| Address addr | the address to bind and listen on. |
| SSLCtx ctx | the provided SSLCtx |
| int backlog | the number of connections to backlog before refusing connection |
| bool reuse | if enabled, allow rebinding of existing ip/port |