| ... | @@ -2,7 +2,8 @@ | ... | @@ -2,7 +2,8 @@ |
| 2 | //! these are "Certificate Authorities" used to validate SSL certificates. | 2 | //! these are "Certificate Authorities" used to validate SSL certificates. |
| 3 | //! This data structure stores certificates in DER-encoded form, all of them | 3 | //! This data structure stores certificates in DER-encoded form, all of them |
| 4 | //! concatenated together in the `bytes` array. The `map` field contains an | 4 | //! concatenated together in the `bytes` array. The `map` field contains an |
| 5 | //! index from the DER-encoded subject name to the index within `bytes`. | 5 | //! index from the DER-encoded subject name to the index of the containing |
| | 6 | //! certificate within `bytes`. |
| 6 | | 7 | |
| 7 | map: std.HashMapUnmanaged(Key, u32, MapContext, std.hash_map.default_max_load_percentage) = .{}, | 8 | map: std.HashMapUnmanaged(Key, u32, MapContext, std.hash_map.default_max_load_percentage) = .{}, |
| 8 | bytes: std.ArrayListUnmanaged(u8) = .{}, | 9 | bytes: std.ArrayListUnmanaged(u8) = .{}, |
| ... | @@ -105,7 +106,12 @@ pub fn addCertsFromFile( | ... | @@ -105,7 +106,12 @@ pub fn addCertsFromFile( |
| 105 | const dest_buf = cb.bytes.allocatedSlice()[decoded_start..]; | 106 | const dest_buf = cb.bytes.allocatedSlice()[decoded_start..]; |
| 106 | cb.bytes.items.len += try base64.decode(dest_buf, encoded_cert); | 107 | cb.bytes.items.len += try base64.decode(dest_buf, encoded_cert); |
| 107 | const k = try key(cb, decoded_start); | 108 | const k = try key(cb, decoded_start); |
| 108 | try cb.map.putContext(gpa, k, decoded_start, .{ .cb = cb }); | 109 | const gop = try cb.map.getOrPutContext(gpa, k, .{ .cb = cb }); |
| | 110 | if (gop.found_existing) { |
| | 111 | cb.bytes.items.len = decoded_start; |
| | 112 | } else { |
| | 113 | gop.value_ptr.* = decoded_start; |
| | 114 | } |
| 109 | } | 115 | } |
| 110 | } | 116 | } |
| 111 | | 117 | |