From faf0fe430518ff544fa26e75f51bf7f104726f68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?fn=20=E2=8C=83=20=E2=8C=A5?= <70830482+FnControlOption@users.noreply.github.com> Date: Tue, 17 Jan 2023 08:56:06 -0800 Subject: [PATCH] std.crypto.Certificate.Bundle: use parseCert in rescanWindows --- lib/std/crypto/Certificate/Bundle.zig | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/lib/std/crypto/Certificate/Bundle.zig b/lib/std/crypto/Certificate/Bundle.zig index 94618c5ef8..1a5a45ae63 100644 --- a/lib/std/crypto/Certificate/Bundle.zig +++ b/lib/std/crypto/Certificate/Bundle.zig @@ -120,21 +120,14 @@ pub fn rescanWindows(cb: *Bundle, gpa: Allocator) !void { }; defer _ = w.crypt32.CertCloseStore(store, 0); + const now_sec = std.time.timestamp(); + var ctx = w.crypt32.CertEnumCertificatesInStore(store, null); while (ctx) |context| : (ctx = w.crypt32.CertEnumCertificatesInStore(store, ctx)) { const decoded_start = @intCast(u32, cb.bytes.items.len); const encoded_cert = context.pbCertEncoded[0..context.cbCertEncoded]; try cb.bytes.appendSlice(gpa, encoded_cert); - const parsed_cert = try Certificate.parse(.{ - .buffer = cb.bytes.items, - .index = decoded_start, - }); - const gop = try cb.map.getOrPutContext(gpa, parsed_cert.subject_slice, .{ .cb = cb }); - if (gop.found_existing) { - cb.bytes.items.len = decoded_start; - } else { - gop.value_ptr.* = decoded_start; - } + try cb.parseCert(gpa, decoded_start, now_sec); } cb.bytes.shrinkAndFree(gpa, cb.bytes.items.len); }