How do I download a web server's SSL certificate using Node.js?

I'd like to download the SSL certificate of a web server, using Node.js. I have seen how to do this using OpenSSL, and this works, but it's not Node.js ;-)

Node.js's function getPeerCertificate (which is available in the tls module, and hence also available in the https module) doesn't help much, because it only returns the metadata and the fingerprint of the certificate, but not the actual certificate.

I know that I could use a child process to run OpenSSL from Node.js, but I wonder whether there is a way to do it only using built-in capabilities.

Any suggestions?