| ... | @@ -50,7 +50,7 @@ pub fn deinit(cb: *Bundle, gpa: Allocator) void { | ... | @@ -50,7 +50,7 @@ pub fn deinit(cb: *Bundle, gpa: Allocator) void { |
| 50 | cb.* = undefined; | 50 | cb.* = undefined; |
| 51 | } | 51 | } |
| 52 | | 52 | |
| 53 | pub const RescanError = RescanLinuxError || RescanMacError || RescanWindowsError; | 53 | pub const RescanError = RescanLinuxError || RescanMacError || RescanBSDError || RescanWindowsError; |
| 54 | | 54 | |
| 55 | /// Clears the set of certificates and then scans the host operating system | 55 | /// Clears the set of certificates and then scans the host operating system |
| 56 | /// file system standard locations for certificates. | 56 | /// file system standard locations for certificates. |
| ... | @@ -60,18 +60,20 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void { | ... | @@ -60,18 +60,20 @@ 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 | .freebsd, .openbsd => return rescanBSD(cb, gpa, "/etc/ssl/cert.pem"), |
| | 64 | .netbsd => return rescanBSD(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"), |
| | 65 | .dragonfly => return rescanBSD(cb, gpa, "/usr/local/etc/ssl/cert.pem"), |
| 64 | .windows => return rescanWindows(cb, gpa), | 66 | .windows => return rescanWindows(cb, gpa), |
| 65 | else => {}, | 67 | else => {}, |
| 66 | } | 68 | } |
| 67 | } | 69 | } |
| 68 | | 70 | |
| 69 | pub const rescanMac = @import("Bundle/macos.zig").rescanMac; | 71 | const rescanMac = @import("Bundle/macos.zig").rescanMac; |
| 70 | pub const RescanMacError = @import("Bundle/macos.zig").RescanMacError; | 72 | const RescanMacError = @import("Bundle/macos.zig").RescanMacError; |
| 71 | | 73 | |
| 72 | pub const RescanLinuxError = AddCertsFromFilePathError || AddCertsFromDirPathError; | 74 | const RescanLinuxError = AddCertsFromFilePathError || AddCertsFromDirPathError; |
| 73 | | 75 | |
| 74 | pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void { | 76 | fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void { |
| 75 | // Possible certificate files; stop after finding one. | 77 | // Possible certificate files; stop after finding one. |
| 76 | const cert_file_paths = [_][]const u8{ | 78 | const cert_file_paths = [_][]const u8{ |
| 77 | "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc. | 79 | "/etc/ssl/certs/ca-certificates.crt", // Debian/Ubuntu/Gentoo etc. |
| ... | @@ -113,22 +115,18 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void { | ... | @@ -113,22 +115,18 @@ pub fn rescanLinux(cb: *Bundle, gpa: Allocator) RescanLinuxError!void { |
| 113 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); | 115 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 114 | } | 116 | } |
| 115 | | 117 | |
| 116 | pub const RescanOpenBSDError = AddCertsFromFilePathError; | 118 | const RescanBSDError = AddCertsFromFilePathError; |
| 117 | | | |
| 118 | pub fn rescanOpenBSD(cb: *Bundle, gpa: Allocator) RescanOpenBSDError!void { | | |
| 119 | const cert_file_path = "/etc/ssl/cert.pem"; | | |
| 120 | | 119 | |
| | 120 | fn rescanBSD(cb: *Bundle, gpa: Allocator, cert_file_path: []const u8) RescanBSDError!void { |
| 121 | cb.bytes.clearRetainingCapacity(); | 121 | cb.bytes.clearRetainingCapacity(); |
| 122 | cb.map.clearRetainingCapacity(); | 122 | cb.map.clearRetainingCapacity(); |
| 123 | | 123 | try addCertsFromFilePathAbsolute(cb, gpa, cert_file_path); |
| 124 | addCertsFromFilePathAbsolute(cb, gpa, cert_file_path) catch |err| return err; | | |
| 125 | | | |
| 126 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); | 124 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 127 | } | 125 | } |
| 128 | | 126 | |
| 129 | pub const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound}; | 127 | const RescanWindowsError = Allocator.Error || ParseCertError || std.os.UnexpectedError || error{FileNotFound}; |
| 130 | | 128 | |
| 131 | pub fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void { | 129 | fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void { |
| 132 | cb.bytes.clearRetainingCapacity(); | 130 | cb.bytes.clearRetainingCapacity(); |
| 133 | cb.map.clearRetainingCapacity(); | 131 | cb.map.clearRetainingCapacity(); |
| 134 | | 132 | |