From 235e9045fc5646e51d7b1551e24bb8cdaef36bc3 Mon Sep 17 00:00:00 2001 From: Vemahk Date: Fri, 5 Jan 2024 20:04:38 -0600 Subject: [PATCH 1/5] readd -Dopenssl to zap build. modify readme for instructions how to use it --- README.md | 1 + build.zig | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 606f8c6..e4dc68b 100644 --- a/README.md +++ b/README.md @@ -273,6 +273,7 @@ Then, in your `build.zig`'s `build` function, add the following before const zap = b.dependency("zap", .{ .target = target, .optimize = optimize, + //.openssl = true, // required to use tls }); exe.addModule("zap", zap.module("zap")); exe.linkLibrary(zap.artifact("facil.io")); diff --git a/build.zig b/build.zig index fe3df08..e71d887 100644 --- a/build.zig +++ b/build.zig @@ -8,7 +8,7 @@ pub fn build(b: *std.build.Builder) !void { const optimize = b.standardOptimizeOption(.{}); // Use an os env var to determine whether to build openssl support - const use_openssl = blk: { + const use_openssl = b.option(bool, "openssl", "Use system-installed openssl for TLS support in zap") orelse blk: { if (std.os.getenv("ZAP_USE_OPENSSL")) |val| { if (std.mem.eql(u8, val, "true")) break :blk true; } From 887cdd8b0e96fa3d130b06885086113515f1a0cd Mon Sep 17 00:00:00 2001 From: Vemahk Date: Fri, 5 Jan 2024 20:15:32 -0600 Subject: [PATCH 2/5] updated relevant comment --- build.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig b/build.zig index e71d887..1a2193a 100644 --- a/build.zig +++ b/build.zig @@ -7,8 +7,8 @@ pub fn build(b: *std.build.Builder) !void { // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. const optimize = b.standardOptimizeOption(.{}); - // Use an os env var to determine whether to build openssl support const use_openssl = b.option(bool, "openssl", "Use system-installed openssl for TLS support in zap") orelse blk: { + // Alternatively, use an os env var to determine whether to build openssl support if (std.os.getenv("ZAP_USE_OPENSSL")) |val| { if (std.mem.eql(u8, val, "true")) break :blk true; } From 8191e82ecadf69ab400f941836e8b8d101bf54c4 Mon Sep 17 00:00:00 2001 From: Vemahk Date: Fri, 5 Jan 2024 20:18:30 -0600 Subject: [PATCH 3/5] README.md change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4dc68b..c6c9140 100644 --- a/README.md +++ b/README.md @@ -273,7 +273,7 @@ Then, in your `build.zig`'s `build` function, add the following before const zap = b.dependency("zap", .{ .target = target, .optimize = optimize, - //.openssl = true, // required to use tls + .openssl = false, // set to true to enable TLS support }); exe.addModule("zap", zap.module("zap")); exe.linkLibrary(zap.artifact("facil.io")); From d39d78d6a7d7017063aee0d5a8ddf8c063ce306d Mon Sep 17 00:00:00 2001 From: Vemahk Date: Fri, 5 Jan 2024 20:26:26 -0600 Subject: [PATCH 4/5] Another README update: for the https FAQ honestly not sure how to concisely express that. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c6c9140..d552429 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,8 @@ Exactly the goals I set out to achieve! - Q: **Does ZAP support TLS / HTTPS?** - A: Yes, ZAP supports using the system's openssl. See the [https](./examples/https/https.zig) example and make sure to build with - the environment variable `ZAP_USE_OPENSSL=true`: + the -Dopenssl flag or the environment variable `ZAP_USE_OPENSSL=true`: + - `.openssl = true,` (in build.zig, `b.dependency("zap" .{...})`) - `ZAP_USE_OPENSSL=true zig build https` ## Here's what works From f38077c780d2a44350fd341c4bc43d1f3bf88540 Mon Sep 17 00:00:00 2001 From: Vemahk Date: Fri, 5 Jan 2024 20:31:34 -0600 Subject: [PATCH 5/5] goodness, there's more README. --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d552429..aad3c3d 100644 --- a/README.md +++ b/README.md @@ -118,10 +118,11 @@ necessary to show a feature. call `r.sendError(err, status_code)` when you catch an error and a stack trace will be returned to the client / browser. - [**HTTPS**](examples/https/https.zig): Shows how easy it is to use facil.io's - openssl support. Must be compiled with the environment variable - `ZAP_USE_OPENSSL` set to `true` and requires openssl dev dependencies + openssl support. Must be compiled with `-Dopenssl=true` or the environment + variable `ZAP_USE_OPENSSL` set to `true` and requires openssl dev dependencies (headers, lib) to be installed on the system. - - run it like this: `ZAP_USE_OPENSSL=true zig build run-https` + - run it like this: `ZAP_USE_OPENSSL=true zig build run-https` + OR like this: `zig build -Dopenssl=true run-https` - it will tell you how to generate certificates I'll continue wrapping more of facil.io's functionality and adding stuff to zap