Zig Requires Chilkat v11.0.0+
Zig
Get Certificate Public Key from PEM
See more Certificates Examples
Demonstrates how to load a PEM file containing a certificate and access 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();
cert.loadFromFile("qa_data/pem/my_cert.pem") catch {
std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
return;
};
const pubkey = try chilkat.PublicKey.init();
defer pubkey.deinit();
cert.getPublicKey(pubkey) catch {};
// Examine the public key as XML..
std.debug.print("{s}\n", .{try pubkey.getXml(alloc)});
}