Skip to content

Commit 614bc67

Browse files
mikdusanandrewrk
authored andcommitted
openbsd: add root certificate scanning
patch by @bilaliscarioth, thank you! closes #16168
1 parent 43c98dc commit 614bc67

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/std/crypto/Certificate/Bundle.zig

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void {
6060
switch (builtin.os.tag) {
6161
.linux => return rescanLinux(cb, gpa),
6262
.macos => return rescanMac(cb, gpa),
63+
.openbsd => return rescanOpenBSD(cb, gpa),
6364
.windows => return rescanWindows(cb, gpa),
6465
else => {},
6566
}
@@ -112,6 +113,19 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void {
112113
cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len);
113114
}
114115

116+
pub const RescanOpenBSDError = AddCertsFromFilePathError;
117+
118+
pub 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+
115129
pub const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound};
116130

117131
pub fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void {

0 commit comments

Comments
 (0)