openbsd: add root certificate scanning

patch by @bilaliscarioth, thank you!

closes #16168
This commit is contained in:
Michael Dusan 2023-06-25 11:38:37 -04:00 committed by Andrew Kelley
parent 43c98dc115
commit 614bc6755e

View file

@ -60,6 +60,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {
switch (builtin.os.tag) { switch (builtin.os.tag) {
.linux => return rescanLinux(cb, gpa), .linux => return rescanLinux(cb, gpa),
.macos => return rescanMac(cb, gpa), .macos => return rescanMac(cb, gpa),
.openbsd => return rescanOpenBSD(cb, gpa),
.windows => return rescanWindows(cb, gpa), .windows => return rescanWindows(cb, gpa),
else => {}, else => {},
} }
@ -112,6 +113,19 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void {
cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
} }
pub const RescanOpenBSDError = AddCertsFromFilePathError;
pub fn rescanOpenBSD(cb: *Bundle, gpa: Allocator) RescanOpenBSDError!void {
const cert_file_path = "/etc/ssl/cert.pem";
cb.bytes.clearRetainingCapacity();
cb.map.clearRetainingCapacity();
addCertsFromFilePathAbsolute(cb, gpa, cert_file_path) catch |err| return err;
cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
}
pub const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound}; pub const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound};
pub fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void { pub fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {