authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-16 21:47:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-17 00:09:34-07:00
log7623f3fad0f077d06ffef9eccdf77cb847e14f35
tree41bfe6a17b8b9c33b1ec9cfb7927ff129945f135
parent86308ba1e11a083f4ec91cf3b0e81a791892f851

std.crypto.Certificate: skip unknown attributes


1 files changed, 9 insertions(+), 2 deletions(-)

lib/std/crypto/Certificate.zig+9-2
......@@ -61,8 +61,10 @@ pub const Attribute = enum {
6161 countryName,
6262 localityName,
6363 stateOrProvinceName,
64 streetAddress,
6465 organizationName,
6566 organizationalUnitName,
67 postalCode,
6668 organizationIdentifier,
6769 pkcs9_emailAddress,
6870 domainComponent,
......@@ -73,8 +75,10 @@ pub const Attribute = enum {
7375 .{ &[_]u8{ 0x55, 0x04, 0x06 }, .countryName },
7476 .{ &[_]u8{ 0x55, 0x04, 0x07 }, .localityName },
7577 .{ &[_]u8{ 0x55, 0x04, 0x08 }, .stateOrProvinceName },
78 .{ &[_]u8{ 0x55, 0x04, 0x09 }, .streetAddress },
7679 .{ &[_]u8{ 0x55, 0x04, 0x0A }, .organizationName },
7780 .{ &[_]u8{ 0x55, 0x04, 0x0B }, .organizationalUnitName },
81 .{ &[_]u8{ 0x55, 0x04, 0x11 }, .postalCode },
7882 .{ &[_]u8{ 0x55, 0x04, 0x61 }, .organizationIdentifier },
7983 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01 }, .pkcs9_emailAddress },
8084 .{ &[_]u8{ 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19 }, .domainComponent },
......@@ -389,13 +393,16 @@ pub fn parse(cert: Certificate) !Parsed {
389393 var atav_i = atav.slice.start;
390394 while (atav_i < atav.slice.end) {
391395 const ty_elem = try der.Element.parse(cert_bytes, atav_i);
392 const ty = try parseAttribute(cert_bytes, ty_elem);
393396 const val = try der.Element.parse(cert_bytes, ty_elem.slice.end);
397 atav_i = val.slice.end;
398 const ty = parseAttribute(cert_bytes, ty_elem) catch |err| switch (err) {
399 error.CertificateHasUnrecognizedObjectId => continue,
400 else => |e| return e,
401 };
394402 switch (ty) {
395403 .commonName => common_name = val.slice,
396404 else => {},
397405 }
398 atav_i = val.slice.end;
399406 }
400407 rdn_i = atav.slice.end;
401408 }