Zig Requires Chilkat v11.0.0+
Zig
Get Certificate's Public Key
Loads a certificate from PEM and gets the public key.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const cert = try chilkat.Cert.init();
defer cert.deinit();
const str_pem = "-----BEGIN CERTIFICATE----- ...";
cert.loadPem(str_pem) catch {
std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
return;
};
const pub_key = try chilkat.PublicKey.init();
defer pub_key.deinit();
cert.getPublicKey(pub_key) catch {};
// You can now use the public key object however it is needed,
// and access its various properties and methods..
std.debug.print("{s}\n", .{try pub_key.getXml(alloc)});
}