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
This commit is contained in:
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

View file

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