Zig
Zig
Load Certificate from Smartcard in Reader (or from USB Token)
See more Certificates Examples
Demonstrates how to load the certificate that is on the smartcard currently inserted into the smartcard reader. (Also can load the smartcard on a USB token.)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();
// If you know the smart card PIN, set it prior to loading from the smartcard/USB token.
cert.setSmartCardPin("12345678");
// Pass an empty string to allow Chilkat to discover the smart card or USB token automatically.
cert.loadFromSmartcard("") catch {
std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
return;
};
std.debug.print("Cert loaded from smartcard: {s}\n", .{try cert.getSubjectCN(alloc)});
}