Skip to content

Commit 5a15066

Browse files
committed
Don't panic if no certs are available
#982
1 parent e486f28 commit 5a15066

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/http/Http.zig

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,8 +331,15 @@ fn loadCerts(allocator: Allocator, arena: Allocator) !c.curl_blob {
331331
try bundle.rescan(allocator);
332332
defer bundle.deinit(allocator);
333333

334-
var it = bundle.map.valueIterator();
335334
const bytes = bundle.bytes.items;
335+
if (bytes.len == 0) {
336+
log.warn(.app, "No system certificates", .{});
337+
return .{
338+
.len = 0,
339+
.flags = 0,
340+
.data = bytes.ptr,
341+
};
342+
}
336343

337344
const encoder = std.base64.standard.Encoder;
338345
var arr: std.ArrayListUnmanaged(u8) = .empty;
@@ -345,6 +352,7 @@ fn loadCerts(allocator: Allocator, arena: Allocator) !c.curl_blob {
345352
try arr.ensureTotalCapacity(arena, buffer_size);
346353
var writer = arr.writer(arena);
347354

355+
var it = bundle.map.valueIterator();
348356
while (it.next()) |index| {
349357
const cert = try std.crypto.Certificate.der.Element.parse(bytes, index.*);
350358

0 commit comments

Comments
 (0)