Module vibe.stream.tls
TLS stream implementation
TLSStream
can be used to implement TLS communication on top of a TCP connection. The
TLSContextKind
of an TLSStream
determines if the TLS tunnel is established actively (client) or
passively (server).
Example
A simple TLS client
import vibe .core .net;
import vibe .stream .ssl;
void sendTLSMessage()
{
auto conn = connectTCP("127.0.0.1", 1234);
auto sslctx = createTLSContext(TLSContextKind .client);
auto stream = createTLSStream(conn, sslctx);
stream .write("Hello, World!");
stream .finalize();
conn .close();
}
Example
Corresponding server
import vibe .core .log;
import vibe .core .net;
import vibe .stream .operations;
import vibe .stream .ssl;
void listenForTLS()
{
auto sslctx = createTLSContext(TLSContextKind .server);
sslctx .useCertificateChainFile("server.crt");
sslctx .usePrivateKeyFile("server.key");
listenTCP(1234, (conn){
auto stream = createTLSStream(conn, sslctx);
logInfo("Got message: %s", stream .readAllUTF8());
stream .finalize();
});
}
Functions
Name | Description |
---|---|
createTLSContext
|
Creates a new context of the given kind .
|
createTLSStream
|
Constructs a new TLS tunnel and infers the stream state from the TLSContextKind .
|
createTLSStream
|
Constructs a new TLS tunnel, allowing to override the stream state .
|
createTLSStreamFL
|
Constructs a new TLS stream using manual memory allocator. |
setTLSContextFactory
|
Interfaces
Name | Description |
---|---|
TLSContext
|
Encapsulates the configuration for an TLS tunnel. |
TLSStream
|
Creates an TLS tunnel within an existing stream. |
Structs
Name | Description |
---|---|
TLSCertificateInformation
|
Certificate information |
TLSPeerValidationData
|
Enums
Name | Description |
---|---|
TLSContextKind
|
|
TLSPeerValidationMode
|
Specifies how rigorously TLS peer certificates are validated. |
TLSStreamState
|
|
TLSVersion
|
Aliases
Name | Type | Description |
---|---|---|
TLSALPNCallback
|
string delegate(string[])
|
|
TLSPeerValidationCallback
|
bool delegate(scope TLSPeerValidationData)
|
|
TLSServerNameCallback
|
TLSContext delegate(string)
|
Authors
Sönke Ludwig
Copyright
© 2012-2014 RejectedSoftware e.K.
License
Subject to the terms of the MIT license, as written in the included LICENSE.txt file.