Read System.keychain as well as SystemRootCertificates.keychain for MacOS CA Bundle

This commit is contained in:
Don 2025-01-31 16:02:42 -06:00 committed by Alex Rønne Petersen
parent ea1ce2df9b
commit b3a11018ae

View File

@ -11,7 +11,13 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void {
cb.bytes.clearRetainingCapacity();
cb.map.clearRetainingCapacity();
const file = try fs.openFileAbsolute("/System/Library/Keychains/SystemRootCertificates.keychain", .{});
const keychainPaths = [2][]const u8{
"/System/Library/Keychains/SystemRootCertificates.keychain",
"/Library/Keychains/System.keychain",
};
for (keychainPaths) |keychainPath| {
const file = try fs.openFileAbsolute(keychainPath, .{});
defer file.close();
const bytes = try file.readToEndAlloc(gpa, std.math.maxInt(u32));
@ -68,6 +74,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void {
try cb.parseCert(gpa, cert_start, now_sec);
}
}
}
cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
}