I need to get a server's public key from its SSL cert. I'm getting the cert as follows:

```
https.request(options, res => {
  const cert = res.connection.getPeerCertificate();
  const publicKey = cert.????()
}

```

I can't find a way to get the public key from the certificate though. Are there any libraries that can do this?

I'm looking to use the public key to encrypt some data:

```
const encryptedBuffer =  crypto.publicEncrypt({
  key: publicKey,
  padding: crypto.constants.RSA_PKCS1_PADDING
}, utf8Payload)

```

I see that the certificate has a "raw" buffer, but using that as the publicKey fails.