authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-06-25 11:38:37-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-06-29 10:29:28-07:00
log614bc6755e99645e529fb0b648ffa34b1e3fc7ff
tree3849ecf0c37dcc7c334b43aecfe3412e99a8e636
parent43c98dc11567eeb38be041c7dad179c53156f3df

openbsd: add root certificate scanning

patch by @bilaliscarioth, thank you! closes #16168

1 files changed, 14 insertions(+), 0 deletions(-)

lib/std/crypto/Certificate/Bundle.zig+14
...@@ -60,6 +60,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {...@@ -60,6 +60,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {
60 switch (builtin.os.tag) {60 switch (builtin.os.tag) {
61 .linux => return rescanLinux(cb, gpa),61 .linux => return rescanLinux(cb, gpa),
62 .macos => return rescanMac(cb, gpa),62 .macos => return rescanMac(cb, gpa),
63 .openbsd => return rescanOpenBSD(cb, gpa),
63 .windows => return rescanWindows(cb, gpa),64 .windows => return rescanWindows(cb, gpa),
64 else => {},65 else => {},
65 }66 }
...@@ -112,6 +113,19 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void {...@@ -112,6 +113,19 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void {
112 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);113 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
113}114}
114115
116pub const RescanOpenBSDError = AddCertsFromFilePathError;
117
118pub fn rescanOpenBSD(cb: *Bundle, gpa: Allocator) RescanOpenBSDError!void {
119 const cert_file_path = "/etc/ssl/cert.pem";
120
121 cb.bytes.clearRetainingCapacity();
122 cb.map.clearRetainingCapacity();
123
124 addCertsFromFilePathAbsolute(cb, gpa, cert_file_path) catch |err| return err;
125
126 cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
127}
128
115pub const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound};129pub const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound};
116130
117pub fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {131pub fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {