Zig Requires Chilkat v10.1.2+
Zig
Load PFX (PKCS#12) and List Certificates
See more Certificates Examples
Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.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_store = try chilkat.CertStore.init();
defer cert_store.deinit();
const pfx_path = "/Users/chilkat/testData/pfx/chilkat_ssl.pfx";
const pfx_password = "test";
cert_store.loadPfxFile(pfx_path, pfx_password) catch {
std.debug.print("{s}\n", .{try cert_store.getLastErrorText(alloc)});
return;
};
const num_certs = cert_store.getNumCertificates();
std.debug.print("PFX contains {d} certificates\n", .{num_certs});
const cert = try chilkat.Cert.init();
defer cert.deinit();
var i: i32 = 0;
while (i < num_certs) {
cert_store.getCert(i, cert) catch {};
std.debug.print("{d}: (Common Name) {s}\n", .{ i, try cert.getSubjectCN(alloc) });
std.debug.print("{d}: (Serial Number) {s}\n", .{ i, try cert.getSerialNumber(alloc) });
std.debug.print("{d}: (Distinguished Name) {s}\n", .{ i, try cert.getSubjectDN(alloc) });
i = i + 1;
}
}