Skip to content

Commit

Permalink
Merge pull request #52 from vibe-d/fix_notls_compilation
Browse files Browse the repository at this point in the history
Fix "notls" compilation
  • Loading branch information
s-ludwig authored Dec 25, 2024
2 parents f907685 + e2e008c commit 4038f23
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions run-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ if [[ $PARTS =~ (^|,)builds(,|$) ]]; then
dub build --combined --arch=x86
dub clean --all-packages
fi

# test for successful notls build
if [ "$DC" == "dmd" ]; then
dub build --override-config vibe-stream:tls/notls
fi
fi

if [[ $PARTS =~ (^|,)unittests(,|$) ]]; then
Expand Down
4 changes: 2 additions & 2 deletions source/vibe/http/internal/http1/server.d
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void handleHTTP1Connection(TLSStreamType)(TCPConnection connection, TLSStreamTyp
HTTPServerSettings settings;
bool keep_alive;

version(HaveNoTLS) {} else {
static if (HaveNoTLS) {} else {
// handle oderly TLS shutdowns
if (tls_stream && tls_stream.empty) break;
}
Expand Down Expand Up @@ -108,7 +108,7 @@ private bool handleRequest(TLSStreamType, Allocator)(StreamProxy http_stream, TC
auto res = FreeListRef!HTTPServerResponse(exchange, settings, request_allocator/*.Scoped_payload*/);
req.tls = res.m_tls = listen_info.tlsContext !is null;
if (req.tls) {
version (HaveNoTLS) assert(false);
static if (HaveNoTLS) assert(false);
else {
static if (is(InterfaceProxy!ConnectionStream == ConnectionStream))
req.clientCertificate = (cast(TLSStream)http_stream).peerCertificate;
Expand Down
2 changes: 1 addition & 1 deletion source/vibe/http/internal/http2/exchange.d
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool handleHTTP2Request(UStream)(ref HTTP2ConnectionStream!UStream stream,
req.tls = istls;

if (req.tls) {
version (HaveNoTLS) assert(false);
static if (HaveNoTLS) assert(false);
else {
static if (is(InterfaceProxy!Stream == Stream))
req.clientCertificate = (cast(TLSStream)stream.connection).peerCertificate;
Expand Down
12 changes: 6 additions & 6 deletions source/vibe/http/server.d
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ import std.typecons;
import std.uri;


version (VibeNoSSL) version = HaveNoTLS;
else version (Have_botan) {}
else version (Have_openssl) {}
else version = HaveNoTLS;
version (VibeNoSSL) enum HaveNoTLS = true;
else version (Have_botan) enum HaveNoTLS = false;
else version (Have_openssl) enum HaveNoTLS = false;
else enum HaveNoTLS = true;

/**************************************************************************************************/
/* Public functions */
Expand Down Expand Up @@ -198,7 +198,7 @@ void handleHTTPConnection(TCPConnection connection, HTTPServerContext context)
import vibe.http.internal.http2.server : handleHTTP2Connection;
import vibe.http.internal.http2.settings : HTTP2ServerContext, HTTP2Settings;

version(HaveNoTLS) {
static if (HaveNoTLS) {
alias TLSStreamType = Stream;
} else {
alias TLSStreamType = ReturnType!(createTLSStreamFL!(InterfaceProxy!Stream));
Expand Down Expand Up @@ -231,7 +231,7 @@ void handleHTTPConnection(TCPConnection connection, HTTPServerContext context)

// If this is a HTTPS server, initiate TLS
if (context.tlsContext) {
version (HaveNoTLS) assert(false, "No TLS support compiled in.");
static if (HaveNoTLS) assert(false, "No TLS support compiled in.");
else {
logDebug("Accept TLS connection: %s", context.tlsContext.kind);
// TODO: reverse DNS lookup for peer_name of the incoming connection for TLS client certificate verification purposes
Expand Down

0 comments on commit 4038f23

Please sign in to comment.