Sample code for 30+ languages & platforms
Zig

OCSP Check Domain's Server Certificate Revocation Status

See more HTTP Examples

Sends an OCSP request to determine the revocation status for an SSL server certificate.

Chilkat Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    const http = try chilkat.Http.init();
    defer http.deinit();

    // Check the revocation status of the SSL server certificate for chilkatsoft.com
    var status: i32 = http.ocspCheck("chilkatsoft.com", 443);

    std.debug.print("chilkatsoft.com status = {d}\n", .{status});

    // The status can have 4 values:
    // -1: Unable to check because of an error.
    //  0: Good
    //  1: Revoked
    //  2: Unknown

    if (status < 0) {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
    }

    // Now check the status for a revoked server certificate.
    status = http.ocspCheck("revoked.badssl.com", 443);

    std.debug.print("revoked.badssl.com status = {d}\n", .{status});
}