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 {...@@ -61,8 +61,10 @@ pub const Attribute = enum {
61 countryName,61 countryName,
62 localityName,62 localityName,
63 stateOrProvinceName,63 stateOrProvinceName,
64 streetAddress,
64 organizationName,65 organizationName,
65 organizationalUnitName,66 organizationalUnitName,
67 postalCode,
66 organizationIdentifier,68 organizationIdentifier,
67 pkcs9_emailAddress,69 pkcs9_emailAddress,
68 domainComponent,70 domainComponent,
...@@ -73,8 +75,10 @@ pub const Attribute = enum {...@@ -73,8 +75,10 @@ pub const Attribute = enum {
73 .{ &[_]u8{ 0x55, 0x04, 0x06 }, .countryName },75 .{ &[_]u8{ 0x55, 0x04, 0x06 }, .countryName },
74 .{ &[_]u8{ 0x55, 0x04, 0x07 }, .localityName },76 .{ &[_]u8{ 0x55, 0x04, 0x07 }, .localityName },
75 .{ &[_]u8{ 0x55, 0x04, 0x08 }, .stateOrProvinceName },77 .{ &[_]u8{ 0x55, 0x04, 0x08 }, .stateOrProvinceName },
78 .{ &[_]u8{ 0x55, 0x04, 0x09 }, .streetAddress },
76 .{ &[_]u8{ 0x55, 0x04, 0x0A }, .organizationName },79 .{ &[_]u8{ 0x55, 0x04, 0x0A }, .organizationName },
77 .{ &[_]u8{ 0x55, 0x04, 0x0B }, .organizationalUnitName },80 .{ &[_]u8{ 0x55, 0x04, 0x0B }, .organizationalUnitName },
81 .{ &[_]u8{ 0x55, 0x04, 0x11 }, .postalCode },
78 .{ &[_]u8{ 0x55, 0x04, 0x61 }, .organizationIdentifier },82 .{ &[_]u8{ 0x55, 0x04, 0x61 }, .organizationIdentifier },
79 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01 }, .pkcs9_emailAddress },83 .{ &[_]u8{ 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x01, 0x09, 0x01 }, .pkcs9_emailAddress },
80 .{ &[_]u8{ 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19 }, .domainComponent },84 .{ &[_]u8{ 0x09, 0x92, 0x26, 0x89, 0x93, 0xF2, 0x2C, 0x64, 0x01, 0x19 }, .domainComponent },
...@@ -389,13 +393,16 @@ pub fn parse(cert: Certificate) !Parsed {...@@ -389,13 +393,16 @@ pub fn parse(cert: Certificate) !Parsed {
389 var atav_i = atav.slice.start;393 var atav_i = atav.slice.start;
390 while (atav_i < atav.slice.end) {394 while (atav_i < atav.slice.end) {
391 const ty_elem = try der.Element.parse(cert_bytes, atav_i);395 const ty_elem = try der.Element.parse(cert_bytes, atav_i);
392 const ty = try parseAttribute(cert_bytes, ty_elem);
393 const val = try der.Element.parse(cert_bytes, ty_elem.slice.end);396 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 };
394 switch (ty) {402 switch (ty) {
395 .commonName => common_name = val.slice,403 .commonName => common_name = val.slice,
396 else => {},404 else => {},
397 }405 }
398 atav_i = val.slice.end;
399 }406 }
400 rdn_i = atav.slice.end;407 rdn_i = atav.slice.end;
401 }408 }