Skip to content

Commit 4935efc

Browse files
authored
Merge pull request #17 from thatsdone/hotfix/14
[enh] add get_oid_value_all() to http/certs/js/x509 example.
2 parents 1222ae9 + 4a83234 commit 4935efc

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

‎njs/http/certs/js/x509.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,29 @@ function is_oid_exist(cert, oid) {
297297
return false;
298298
}
299299

300+
// returns all the matching field with the specified 'oid' as a list
301+
function get_oid_value_all(cert, oid) {
302+
303+
var values = [];
304+
305+
for (var n = 0; n < cert.length; n++) {
306+
if (Array.isArray(cert[n])) {
307+
var r = get_oid_value_all(cert[n], oid);
308+
if (r.length > 0) {
309+
values = values.concat(r);
310+
}
311+
} else {
312+
if (cert[n] == oid) {
313+
if (n < cert.length) {
314+
// push next element in array
315+
values.push(cert[n+1]);
316+
}
317+
}
318+
}
319+
}
320+
return values;
321+
}
322+
300323
function get_oid_value(cert, oid) {
301324
for (var n = 0; n < cert.length; n++) {
302325
if (Array.isArray(cert[n])) {
@@ -327,4 +350,4 @@ function parse_pem_cert(pem) {
327350
return asn1_read(der);
328351
}
329352

330-
export default {asn1_read, parse_pem_cert, is_oid_exist, get_oid_value};
353+
export default {asn1_read, parse_pem_cert, is_oid_exist, get_oid_value, get_oid_value_all};

0 commit comments

Comments
 (0)