Skip to content

make EcdsaKeyPair tagged union public together with its init function#22

Merged
ianic merged 2 commits intoianic:mainfrom
Mariuspersen:main
Jan 7, 2026
Merged

make EcdsaKeyPair tagged union public together with its init function#22
ianic merged 2 commits intoianic:mainfrom
Mariuspersen:main

Conversation

@Mariuspersen
Copy link
Contributor

I have a use case where I wanted the certs to be embedded into the binary and was unable to do so due to EcdsaKeyPair tagged union init function being private, with the tagged union being public I can now do something like this:

pub fn init(alloc: Allocator, comptime cert: []const u8, comptime key: []const u8) !CertKeyPair {
    var bundle = Bundle{};
    try addCertsFromSlice(&bundle, alloc, cert);
    return .{
        .key = try .parsePem(key),
        .ecdsa_key_pair = try .init(try .parsePem(key)),
        .bundle = bundle,
    };
}

Thought this change might be useful, feel free to ignore if it's not something you want or if its a bad idea

@ianic
Copy link
Owner

ianic commented Jan 6, 2026

Sorry for letting this linger for so long.

Can you change that into method of the CertKeyPair. So we have
CertKeyPair.fromSlices(allocator, cert: []const u8, key: []const u8)` where cert and key are slices of data not a file path.

@Mariuspersen
Copy link
Contributor Author

Oh my bad, the code in the comment is just a example, I just require the init function to EcdsaKeyPair be marked as public.
I have some additional hacks on my end to get Certificates from slices.
But I can definitely make a fromSlices function for CertKeyPair if you want.

I'm looking at the diff in the changed files and it looks terrible, my bad.

@Mariuspersen Mariuspersen reopened this Jan 7, 2026
@Mariuspersen
Copy link
Contributor Author

Something like this?

No errors with zig build tests and zig build integration

@ianic ianic merged commit 38b46d7 into ianic:main Jan 7, 2026
0 of 2 checks passed
@ianic
Copy link
Owner

ianic commented Jan 7, 2026

Thanks!

I needed to fix paths (remove root) in order to pass zig build integration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants