also looking at this
Harden encrypted mail storage, recovery, and forwarding
#8
50 files
+1701
-9001
| @@ -1,62 +0,0 @@ | ||
| 1 | # zig-tls | |
| 2 | ||
| 3 | Pure Zig TLS 1.3 implementation for SMTP and other protocols. | |
| 4 | ||
| 5 | ## Features | |
| 6 | ||
| 7 | - TLS 1.3 client and server support | |
| 8 | - Pure Zig implementation (no C dependencies) | |
| 9 | - Non-blocking I/O | |
| 10 | - STARTTLS support for protocol upgrades | |
| 11 | - Certificate and private key management | |
| 12 | ||
| 13 | ## Installation | |
| 14 | ||
| 15 | Add to your `build.zig.zon`: | |
| 16 | ||
| 17 | ```zig | |
| 18 | .dependencies = .{ | |
| 19 | .tls = .{ | |
| 20 | .path = "../zig-tls", | |
| 21 | }, | |
| 22 | }, | |
| 23 | ``` | |
| 24 | ||
| 25 | Add to your `build.zig`: | |
| 26 | ||
| 27 | ```zig | |
| 28 | const tls = b.dependency("tls", .{ | |
| 29 | .target = target, | |
| 30 | .optimize = optimize, | |
| 31 | }); | |
| 32 | exe.root_module.addImport("tls", tls.module("tls")); | |
| 33 | ``` | |
| 34 | ||
| 35 | ## Usage | |
| 36 | ||
| 37 | ### Server Example | |
| 38 | ||
| 39 | ```zig | |
| 40 | const tls = @import("tls"); | |
| 41 | ||
| 42 | // Load certificate and key | |
| 43 | var cert_key = try tls.config.CertKeyPair.fromFilePathAbsolute( | |
| 44 | allocator, | |
| 45 | "/path/to/cert.pem", | |
| 46 | "/path/to/key.pem", | |
| 47 | ); | |
| 48 | defer cert_key.deinit(allocator); | |
| 49 | ||
| 50 | // Create TLS connection from stream | |
| 51 | const tls_conn = try tls.serverFromStream(stream, .{ | |
| 52 | .auth = &cert_key, | |
| 53 | }); | |
| 54 | ||
| 55 | // Read/write through TLS | |
| 56 | const n = try tls_conn.read(buffer); | |
| 57 | try tls_conn.write(data); | |
| 58 | ``` | |
| 59 | ||
| 60 | ## License | |
| 61 | ||
| 62 | MIT - Based on https://github.com/ianic/tls.zig | |