Commit 614bc6755e

Michael Dusan <michael.dusan@gmail.com>
2023-06-25 17:38:37
openbsd: add root certificate scanning
patch by @bilaliscarioth, thank you! closes #16168
1 parent 43c98dc
Changed files (1)
lib
std
crypto
Certificate
lib/std/crypto/Certificate/Bundle.zig
@@ -60,6 +60,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {
     switch (builtin.os.tag) {
         .linux => return rescanLinux(cb, gpa),
         .macos => return rescanMac(cb, gpa),
+        .openbsd => return rescanOpenBSD(cb, gpa),
         .windows => return rescanWindows(cb, gpa),
         else => {},
     }
@@ -112,6 +113,19 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void {
     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 fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {