| ... | ... | @@ -63,8 +63,8 @@ pub fn rescan(cb: *Bundle, gpa: Allocator) RescanError!void { |
| 63 | 63 | .freebsd, .openbsd => return rescanBSD(cb, gpa, "/etc/ssl/cert.pem"), |
| 64 | 64 | .netbsd => return rescanBSD(cb, gpa, "/etc/openssl/certs/ca-certificates.crt"), |
| 65 | 65 | .dragonfly => return rescanBSD(cb, gpa, "/usr/local/etc/ssl/cert.pem"), |
| 66 | .solaris, .illumos => return rescanBSD(cb, gpa, "/etc/ssl/cacert.pem"), |
| 66 | 67 | .windows => return rescanWindows(cb, gpa), |
| 67 | | .solaris, .illumos => return rescanSolaris(cb, gpa, "/etc/ssl/cacert.pem"), |
| 68 | 68 | else => {}, |
| 69 | 69 | } |
| 70 | 70 | } |
| ... | ... | @@ -152,15 +152,6 @@ fn rescanWindows(cb: *Bundle, gpa: Allocator) RescanWindowsError!void { |
| 152 | 152 | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | | const RescanSolarisError = AddCertsFromFilePathError; |
| 156 | | |
| 157 | | fn rescanSolaris(cb: *Bundle, gpa: Allocator, cert_file_path: []const u8) RescanSolarisError!void { |
| 158 | | cb.bytes.clearRetainingCapacity(); |
| 159 | | cb.map.clearRetainingCapacity(); |
| 160 | | try addCertsFromFilePathAbsolute(cb, gpa, cert_file_path); |
| 161 | | cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); |
| 162 | | } |
| 163 | | |
| 164 | 155 | pub const AddCertsFromDirPathError = fs.File.OpenError || AddCertsFromDirError; |
| 165 | 156 | |
| 166 | 157 | pub fn addCertsFromDirPath( |
| ... | ... | @@ -223,7 +214,12 @@ pub fn addCertsFromFilePath( |
| 223 | 214 | return addCertsFromFile(cb, gpa, file); |
| 224 | 215 | } |
| 225 | 216 | |
| 226 | | pub const AddCertsFromFileError = Allocator.Error || fs.File.GetSeekPosError || fs.File.ReadError || ParseCertError || std.base64.Error || error{ CertificateAuthorityBundleTooBig, MissingEndCertificateMarker }; |
| 217 | pub const AddCertsFromFileError = Allocator.Error || |
| 218 | fs.File.GetSeekPosError || |
| 219 | fs.File.ReadError || |
| 220 | ParseCertError || |
| 221 | std.base64.Error || |
| 222 | error{ CertificateAuthorityBundleTooBig, MissingEndCertificateMarker }; |
| 227 | 223 | |
| 228 | 224 | pub fn addCertsFromFile(cb: *Bundle, gpa: Allocator, file: fs.File) AddCertsFromFileError!void { |
| 229 | 225 | const size = try file.getEndPos(); |
| ... | ... | @@ -235,7 +231,7 @@ pub fn addCertsFromFile(cb: *Bundle, gpa: Allocator, file: fs.File) AddCertsFrom |
| 235 | 231 | const needed_capacity = std.math.cast(u32, decoded_size_upper_bound + size) orelse |
| 236 | 232 | return error.CertificateAuthorityBundleTooBig; |
| 237 | 233 | try cb.bytes.ensureUnusedCapacity(gpa, needed_capacity); |
| 238 | | const end_reserved = @as(u32, @intCast(cb.bytes.items.len + decoded_size_upper_bound)); |
| 234 | const end_reserved: u32 = @intCast(cb.bytes.items.len + decoded_size_upper_bound); |
| 239 | 235 | const buffer = cb.bytes.allocatedSlice()[end_reserved..]; |
| 240 | 236 | const end_index = try file.readAll(buffer); |
| 241 | 237 | const encoded_bytes = buffer[0..end_index]; |
| ... | ... | @@ -252,7 +248,7 @@ pub fn addCertsFromFile(cb: *Bundle, gpa: Allocator, file: fs.File) AddCertsFrom |
| 252 | 248 | return error.MissingEndCertificateMarker; |
| 253 | 249 | start_index = cert_end + end_marker.len; |
| 254 | 250 | const encoded_cert = mem.trim(u8, encoded_bytes[cert_start..cert_end], " \t\r\n"); |
| 255 | | const decoded_start = @as(u32, @intCast(cb.bytes.items.len)); |
| 251 | const decoded_start: u32 = @intCast(cb.bytes.items.len); |
| 256 | 252 | const dest_buf = cb.bytes.allocatedSlice()[decoded_start..]; |
| 257 | 253 | cb.bytes.items.len += try base64.decode(dest_buf, encoded_cert); |
| 258 | 254 | try cb.parseCert(gpa, decoded_start, now_sec); |