From 6e75a0caa9daf4fa523a959fa83befad3550f55f Mon Sep 17 00:00:00 2001 From: Halil Durak Date: Wed, 1 Jul 2026 11:57:10 +0300 Subject: [PATCH] `libcrypto`: bind couple X509, X509_STORE and SSL_CTX helpers --- src/sys/libcrypto.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/sys/libcrypto.zig b/src/sys/libcrypto.zig index 0e62df336..1e47f8a69 100644 --- a/src/sys/libcrypto.zig +++ b/src/sys/libcrypto.zig @@ -343,6 +343,26 @@ pub extern fn EVP_MD_CTX_free(ctx: ?*EVP_MD_CTX) void; pub const struct_evp_md_ctx_st = opaque {}; pub const EVP_MD_CTX = struct_evp_md_ctx_st; +pub extern fn X509_free(x509: ?*X509) void; +pub extern fn d2i_X509(out: [*c]?*X509, inp: *[*]const u8, len: c_long) ?*X509; + +//pub const struct_x509_store_ctx_st = opaque {}; +//pub const X509_STORE_CTX = struct_x509_store_ctx_st; +pub const struct_x509_store_st = opaque {}; +pub const X509_STORE = struct_x509_store_st; + +pub extern fn X509_STORE_new() ?*X509_STORE; +pub extern fn X509_STORE_free(store: *X509_STORE) void; +pub extern fn X509_STORE_add_cert(store: ?*X509_STORE, x: ?*X509) c_int; +pub extern fn X509_STORE_add_crl(store: ?*X509_STORE, x: ?*X509_CRL) c_int; + +pub const struct_ssl_ctx_st = opaque {}; +pub const SSL_CTX = struct_ssl_ctx_st; +/// SSL_CTX takes ownership. +pub extern fn SSL_CTX_set0_verify_cert_store(ctx: ?*SSL_CTX, store: ?*X509_STORE) c_int; +/// Ownership remains, ref count increments. +pub extern fn SSL_CTX_set1_verify_cert_store(ctx: ?*SSL_CTX, store: ?*X509_STORE) c_int; + /// Returns the desired digest by its name. pub fn findDigest(name: []const u8) error{Invalid}!*const EVP_MD { if (std.mem.eql(u8, "SHA-256", name)) {