tlsSocket.getPeerCertificate()
doesn't document format of valid_from
/ valid_to
#56462
Labels
doc
Issues and PRs related to the documentations.
Affected URL(s)
https://nodejs.org/api/tls.html#tlssocketgetpeercertificatedetailed
Description of the problem
The "Certificate object" returned from
getPeerCertificate
is merely documented as,First, these would be better as
Date
s, but I'm assuming that such a change cannot be made, as it would be a breaking change.In lieu of that … the documentation should specify what format these strings are in. Unfortunately, it appears that these strings are in the format:
which isn't in any standardized format I'm aware of. It appears to be the output of
ASN1_TIME_print
from OpenSSL.It would be nice to note at least that much; maybe, an example of the output?
Since this necessitates anyone wanting to use the data for more than printing to write a parser, I'll also note the following:
OpenSSL's documentation also doesn't really document this format, instead only saying,
Note that the example in the documentation is wrong; AFAICT with examples, that would output
Feb 3 00:55:52 2015 GMT
, notFeb 3 00:55:52 2015 GMT
.ASN1_TIME_print
seems to be equivalent to callingASN1_TIME_print_ex
withflags
set toASN1_DTFLGS_RFC822
(but don't let the name fool you, it's not RFC 822 format, which is like25 Mar 25
, which matches nothing seen thus far…)So
DD
= "space padded" day number, and the[GMT]
is concerning, so I dug into OpenSSL's code to see in what circumstances it would be omitted.The exact code is in
ossl_asn1_time_print_ex
in OpenSSL, but to save anyone the time, one of two format strings get used:With those replacements being 3-char month, day, hour:min:sec, (fractional sec, only for GeneralizedTime), year, and then " GMT" or ""; if the datetime is in GMT, then " GMT", if it's not, then "" — (and the string is thus mangled; AFAICT the underlying data has a UTC offset, it's just not printed!)
Cf. openssl/openssl#26313 — I've asked if OpenSSL can't also document this a little more, too.
The text was updated successfully, but these errors were encountered: