Libtls_ez - A highish level Zig binding for libtls

Hello.

I was recently writing a toy Gemini server, for which you need TLS 1.2/3 + SNI and after bouncing off various options ending up using libtls from libressl.

I wrote some Zig bindings, and ended up wrapping it into a separate repo.

here it is: joshuao/libtls_ez: A highish level Zig binding for libtls - Codeberg.org

It’s “support” lifetime is almost certainly measured in weeks, before I get bored of my toy server, but maybe someone would use it as a starting point.

special thanks to torque on github, who already did the actually hard work of building libressl with build.zig GitHub - allyourcodebase/libressl

Let me know any thoughts!

2 Likes

Thanks for posting this! I saw your other post about keeping return memory locations stable. Options for keeping return memory location stable

I’m also struggling with a c-library that has a lot of callbacks, so I’ll be looking through how you organized yours for some tips.

1 Like

I think I got off easy here, there’s just the 2 callbacks and I think the lifetime is relatively clear for this library (though mostly not documented…).

I have just added an example which uses the callbacks, in this case it’s to wed the TLS with a very much async completion-based event loop (libxev)

It’s fairly gnarly, and probably a good reason not to use a proactor loop for such stuff, but I wanted at least one example of why you’d use the callback mechanism.