Zig Requires Chilkat v11.0.0+
Zig
Get Public Key from Certificate PEM
See more Certificates Examples
Loads a certificate from a PEM file and gets the cert's 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/certs/someCert.pem") catch {
std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
return;
};
// Get the certificate's public key:
const pubkey = try chilkat.PublicKey.init();
defer pubkey.deinit();
cert.getPublicKey(pubkey) catch {};
std.debug.print("{s}\n", .{try pubkey.getPem(alloc, false)});
// OK.. we have the public key which can be used in other Chilkat classes/methods...
}