vibe.d beta banner
get vibe.d
0.8.1

Asynchronous I/O that doesn’t get in your way, written in D

Module vibe.stream.ssl

SSL/TLS stream implementation

SSLStream can be used to implement SSL/TLS communication on top of a TCP connection. The SSLContextKind of an SSLStream determines if the SSL tunnel is established actively (client) or passively (server).

Example

A simple SSL client

import vibe.core.net;
import vibe.stream.ssl;

void sendSSLMessage()
{
	auto conn = connectTCP("127.0.0.1", 1234);
	auto sslctx = createSSLContext(SSLContextKind.client);
	auto stream = createSSLStream(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 listenForSSL()
{
	auto sslctx = createSSLContext(SSLContextKind.server);
	sslctx.useCertificateChainFile("server.crt");
	sslctx.usePrivateKeyFile("server.key");
	listenTCP(1234, (conn){
		auto stream = createSSLStream(conn, sslctx);
		logInfo("Got message: %s", stream.readAllUTF8());
		stream.finalize();
	});
}

Functions

NameDescription
createSSLContext(kind, ver)Creates a new context of the given kind.
createSSLStream(underlying, ctx, peer_name, peer_address)Constructs a new SSL tunnel and infers the stream state from the SSLContextKind.
createSSLStream(underlying, ctx, state, peer_name, peer_address)Constructs a new SSL tunnel, allowing to override the stream state.
createSSLStreamFL(underlying, ctx, state, peer_name, peer_address)Constructs a new SSL stream using manual memory allocator.
setSSLContextFactory(factory)

Interfaces

NameDescription
SSLContextEncapsulates the configuration for an SSL tunnel.
SSLStreamCreates an SSL/TLS tunnel within an existing stream.

Structs

NameDescription
SSLCertificateInformationCertificate information
SSLPeerValidationData

Enums

NameDescription
SSLContextKind
SSLPeerValidationModeSpecifies how rigorously SSL peer certificates are validated.
SSLStreamState
SSLVersion

Aliases

NameTypeDescription
SSLPeerValidationCallbackbool delegate(scope SSLPeerValidationData)
SSLServerNameCallbackSSLContext 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.