Zig
Zig
Get Issuer Certificate Information
See more Certificates Examples
A certificate contains information about its issuer. This example demonstrates how to get the issuer information from a certificate.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/sample.cer") catch {
std.debug.print("{s}\n", .{try cert.getLastErrorText(alloc)});
return;
};
// Get issuer information:
// -----------------------------------------------------------------------
// (Not all subject fields may exist depending on the issuer certificate.)
// -----------------------------------------------------------------------
// Issuer DN (Distinguished Name, i.e. all the Issuer subject parts)
std.debug.print("DN: {s}\n", .{try cert.getIssuerDN(alloc)});
// Common Subject parts:
// Issuer Common Name
std.debug.print("CN: {s}\n", .{try cert.getIssuerCN(alloc)});
// Issuer Country
std.debug.print("C: {s}\n", .{try cert.getIssuerC(alloc)});
// Issuer Email address
std.debug.print("E: {s}\n", .{try cert.getIssuerE(alloc)});
// Issuer Locality
std.debug.print("L: {s}\n", .{try cert.getIssuerL(alloc)});
// Issuer Organization
std.debug.print("O: {s}\n", .{try cert.getIssuerO(alloc)});
// Issuer Organizational Unit
std.debug.print("OU: {s}\n", .{try cert.getIssuerOU(alloc)});
// Issuer State
std.debug.print("S: {s}\n", .{try cert.getIssuerS(alloc)});
}