Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/haze/zig-libressl
LibreSSL stream wrappers for Zig
https://github.com/haze/zig-libressl
Last synced: 3 months ago
JSON representation
LibreSSL stream wrappers for Zig
- Host: GitHub
- URL: https://github.com/haze/zig-libressl
- Owner: haze
- License: bsd-2-clause
- Created: 2021-09-09T16:16:25.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-03-30T05:01:39.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T10:43:49.894Z (3 months ago)
- Language: Zig
- Size: 118 KB
- Stars: 29
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-zig - zig-libressl🗒️LibreSSL stream wrappers for Zig
README
Zig-LibreSSL
Zig-LibreSSL is an idiomatic zig wrapper around LibreSSL's libTLS for `std.net.Stream`## Project status
Zig-LibreSSL is currently a work in progress. I've hand verified that simple
message transactions work, along with use in a homebrewed HTTP client, but there
is still much more to test! Please feel free to open issues for features you
want, or bugs that you encounter.## Quickstart Client
```zig
const std = @import("std");pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer _ = gpa.deinit();var tls_configuration = (TlsConfigurationParams{}).build() catch unreachable;
var connection = try std.net.tcpConnectToHost(&gpa.allocator, "haz.ee", 443);
var ssl_connection = try SslStream.wrapClientStream(tls_configuration, connection, "haz.ee");
defer ssl_connection.deinit();var writer = ssl_connection.writer();
var reader = ssl_connection.reader();try writer.writeAll("GET / HTTP/1.1\n\n");
while (try reader.readUntilDelimiterOrEofAlloc(&gpa.allocator, '\n', std.math.maxInt(usize))) |line| {
std.debug.print("{s}\n", .{line});
defer gpa.allocator.free(line);
if (std.mem.eql(u8, line, "