diff --git a/ChangeLog.txt b/ChangeLog.txt index 7b0b0f2c..65337f67 100755 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,21 @@ ChangeLog for jsrsasign +add CSR support for subjectAltName +* Changes From 8.0.19 to 8.0.20 + - src/asn1csr.js + - CSRUtil.getInfo + - add ext parameter to show subjectAltName property + - change not to raise error when subject name is empty in CSR + - src/x509.js + - X509.parseExt + - add support for CSR extension request field + - src/asn1hex.js + - ASN1HEX.getIdxbyList + - small update for exception + - test/ + - qunit-do-{asn1csr, x509}.html to add tests for above. + ECDSA signature validation maleability fix and others * Changes from 8.0.18 to 8.0.19 - src/ecdsa-mod.js diff --git a/LICENSE.txt b/LICENSE.txt index 28e74055..83d18913 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,7 +1,7 @@ The 'jsrsasign'(RSA-Sign JavaScript Library) License -Copyright (c) 2010-2018 Kenji Urushima +Copyright (c) 2010-2020 Kenji Urushima Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/api/files.html b/api/files.html index 5c7be14a..ca86d5ee 100644 --- a/api/files.html +++ b/api/files.html @@ -500,7 +500,7 @@
o = KJUR.asn1.csr.CSRUtil.getInfo("-----BEGIN CERTIFICATE REQUEST..."); -console.log(o.subject.name) → "/C=US/O=Test"+
KJUR.asn1.csr.CSRUtil.getInfo("-----BEGIN CERTIFICATE REQUEST...") → +{ + subject: { name: "/C=US/O=Test", hex: "30..." }, + pubkey: { hex: "30...", obj: KEYOBJECT }, + ext: [ { subjectAltName: { array: [["DNS", "example.com"]] } } ] +}diff --git a/api/symbols/X509.html b/api/symbols/X509.html index 28a7766e..b62f815f 100644 --- a/api/symbols/X509.html +++ b/api/symbols/X509.html @@ -894,9 +894,9 @@
x = new X509(); x.readCertPEM(sCertPEM); // parseExt() will also be called internally. +x.aExtInfo → +[ { oid: "2.5.29,19", critical: true, vidx: 2504 }, ... ] + +// to parse CSR +X = new X509() +x.parseExt("-----BEGIN CERTIFICATE REQUEST-----..."); x.aExtInfo → [ { oid: "2.5.29,19", critical: true, vidx: 2504 }, ... ]+
1 /* asn1csr-1.0.6.js (c) 2015-2018 Kenji Urushima | kjur.github.com/jsrsasign/license +1 /* asn1csr-1.0.7.js (c) 2015-2020 Kenji Urushima | kjur.github.com/jsrsasign/license 2 */ 3 /* 4 * asn1csr.js - ASN.1 DER encoder classes for PKCS#10 CSR 5 * - 6 * Copyright (c) 2015-2018 Kenji Urushima (kenji.urushima@gmail.com) + 6 * Copyright (c) 2015-2020 Kenji Urushima (kenji.urushima@gmail.com) 7 * 8 * This software is licensed under the terms of the MIT License. 9 * https://kjur.github.io/jsrsasign/license @@ -23,7 +23,7 @@ 16 * @fileOverview 17 * @name asn1csr-1.0.js 18 * @author Kenji Urushima kenji.urushima@gmail.com - 19 * @version jsrsasign 8.0.5 asn1csr 1.0.6 (2018-Jan-13) + 19 * @version jsrsasign 8.0.20 asn1csr 1.0.7 (2020-Jun-24) 20 * @since jsrsasign 4.9.0 21 * @license <a href="https://kjur.github.io/jsrsasign/license/">MIT License</a> 22 */ @@ -426,33 +426,52 @@ 419 * <li>subject.hex - hexadecimal string of X.500 Name of subject</li> 420 * <li>pubkey.obj - subject public key object such as RSAKey, KJUR.crypto.{ECDSA,DSA}</li> 421 * <li>pubkey.hex - hexadecimal string of subject public key</li> -422 * </ul> -423 * -424 * @example -425 * o = KJUR.asn1.csr.CSRUtil.getInfo("-----BEGIN CERTIFICATE REQUEST..."); -426 * console.log(o.subject.name) → "/C=US/O=Test" -427 */ -428 KJUR.asn1.csr.CSRUtil.getInfo = function(sPEM) { -429 var _ASN1HEX = ASN1HEX; -430 var _getTLVbyList = _ASN1HEX.getTLVbyList; -431 -432 var result = {}; -433 result.subject = {}; -434 result.pubkey = {}; -435 -436 if (sPEM.indexOf("-----BEGIN CERTIFICATE REQUEST") == -1) -437 throw "argument is not PEM file"; +422 * <li>ext - array of extensionRequest parameters</li> +423 * </ul> +424 * NOTE: 'ext' property is supported since jsrsasign 8.0.20 asn1csr 1.0.7 and +425 * ext only support subjectAltName extension at current stage. +426 * +427 * @example +428 * KJUR.asn1.csr.CSRUtil.getInfo("-----BEGIN CERTIFICATE REQUEST...") → +429 * { +430 * subject: { name: "/C=US/O=Test", hex: "30..." }, +431 * pubkey: { hex: "30...", obj: KEYOBJECT }, +432 * ext: [ { subjectAltName: { array: [["DNS", "example.com"]] } } ] +433 * } +434 */ +435 KJUR.asn1.csr.CSRUtil.getInfo = function(sPEM) { +436 var _ASN1HEX = ASN1HEX; +437 var _getTLVbyList = _ASN1HEX.getTLVbyList; 438 -439 var hex = pemtohex(sPEM, "CERTIFICATE REQUEST"); -440 -441 result.subject.hex = _getTLVbyList(hex, 0, [0, 1]); -442 result.subject.name = X509.hex2dn(result.subject.hex); -443 -444 result.pubkey.hex = _getTLVbyList(hex, 0, [0, 2]); -445 result.pubkey.obj = KEYUTIL.getKey(result.pubkey.hex, null, "pkcs8pub"); -446 -447 return result; -448 }; -449 -450 -451