Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

Awesome Lists containing this project

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, "