Update to understand Generalized / UTC Time

Future proofing for when certificates with dates after 2049 begin being issued.
These certificates' dates will be in Generalized Time not UTC Time as per RFC 5280
master
Edward Wall 2018-12-30 16:46:18 +00:00 committed by GitHub
parent 688c2d0df5
commit 40acf751a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 6 deletions

View File

@ -206,13 +206,19 @@ ${extensions}`;
* @returns {string} * @returns {string}
*/ */
function formatDate (dateStr) { function formatDate (dateStr) {
return dateStr[4] + dateStr[5] + "/" + if (dateStr.length === 13) { // UTC Time
dateStr[2] + dateStr[3] + "/" + if (dateStr[0] < "5") {
(dateStr[0] < "5" ? "20" : "19") + dateStr = "20" + dateStr;
dateStr[0] + dateStr[1] + " " + } else {
dateStr[6] + dateStr[7] + ":" + dateStr = "19" + dateStr;
}
}
return dateStr[6] + dateStr[7] + "/" +
dateStr[4] + dateStr[5] + "/" +
dateStr[0] + dateStr[1] + dateStr[2] + dateStr[3] + " " +
dateStr[8] + dateStr[9] + ":" + dateStr[8] + dateStr[9] + ":" +
dateStr[10] + dateStr[11]; dateStr[10] + dateStr[11] + ":" +
dateStr[12] + dateStr[13];
} }
export default ParseX509Certificate; export default ParseX509Certificate;