Zig Requires Chilkat v10.1.2+
Zig
Find a Certificate in the "Other People" Windows Certificate Store
See more Certificates Examples
Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address.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();
// The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
const read_only = true;
cert_store.openWindowsStore("CurrentUser", "AddressBook", read_only) catch {
std.debug.print("{s}\n", .{try cert_store.getLastErrorText(alloc)});
return;
};
// Find the certificate for the email address:
const json_e = try chilkat.JsonObject.init();
defer json_e.deinit();
json_e.updateString("email", "joe@example.com") catch {};
const cert = try chilkat.Cert.init();
defer cert.deinit();
cert_store.findCert(json_e, cert) catch {
std.debug.print("{s}\n", .{try cert_store.getLastErrorText(alloc)});
return;
};
std.debug.print("Found certificate: {s}\n", .{try cert.getSubjectDN(alloc)});
}