Repository: deno
Issue: Uncaught (in promise) TypeError: res.socket.getPeerCertificate is not a function
Labels: bug,tls,node compat,node API

```sh
docker run -i --rm --entrypoint=bash node:20.11-bookworm <<'EZZE'
curl -fsSL https://deno.land/install.sh | sh
export DENO_INSTALL="/root/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
echo ===OPENSSL===
echo | openssl s_client -servername httpbin.org -connect httpbin.org:443 2>/dev/null | openssl x509 -noout -enddate
echo ===CURL===
curl --insecure --verbose https://httpbin.org 2>&1 | grep 'expire date'
echo ===nodejs===
node - <<'EOOOF'
const tls = require('tls');
const https = require('https');
const host = 'httpbin.org';
const options = { host, rejectUnauthorized: false};
const req = https.request(options, (res) => {
  const cert = res.socket.getPeerCertificate();
  console.log(`The certificate for ${host} expires on: ${cert.valid_to}`);
  res.on('data', () => {});
  res.on('end', () => {});
});
req.end();
EOOOF
echo ==deno info===
export DENO_INSTALL="/root/.deno"
export PATH="$DENO_INSTALL/bin:$PATH"
deno --version
deno info
env
echo ==deno===
deno run -A - <<'EOOOF'
import * as tls from 'node:tls';
import * as https from 'node:https';
const host = 'httpbin.org';
const options = { host, rejectUnauthorized: false};
const req = https.request(options, (res) => {
  // https://github.com/denoland/deno/blob/345423cf7697326258ce8b32f681910f4a2f77de/ext/node/polyfills/_tls_wrap.ts#L208
  const cert = res.socket.getPeerCertificate();
  console.log(`The certificate for ${host} expires on: ${cert.valid_to}`);
  res.on('data', () => {});
  res.on('end', () => {});
});
req.end();
EOOOF
echo ==deno+curl===
deno run -A - <<'EOOOF'
let cmd = new Deno.Command("curl", { args: ["--insecure","--verbose","https://httpbin.org"] });
let { code, stdout, stderr } = await cmd.output();
const curlverbose=new TextDecoder().decode(stderr)
// GPT4 work
function getExpireDate(text) {
  // Use regex to find the expire date line
  const expireDateRegex = /\*  expire date: (.*)/g;
  const match = expireDateRegex.exec(text);
  // If found, parse the date string to a Date object
  if (match && match[1]) {
    const expireDateString = match[1].trim();
    const expireDate = new Date(expireDateString);
    return expireDate;
  } else {
    throw new Error('Expire date not found in the text');
  }
}
try {
  const expireDate = getExpireDate(curlverbose);
  console.log(`Expire Date: ${expireDate}`); // Outputs: Expire Date: Sat Oct 18 2024 23:59:59 GMT+0000 (Coordinated Universal Time)
} catch (error) {
  console.error(error.message);
}
EOOOF
EZZE
```
output

```
===OPENSSL===
notAfter=Oct 18 23:59:59 2024 GMT
===CURL===
*  expire date: Oct 18 23:59:59 2024 GMT
===nodejs===
The certificate for httpbin.org expires on: Oct 18 23:59:59 2024 GMT
==deno info===
deno 1.40.2 (release, x86_64-unknown-linux-gnu)
v8 12.1.285.6
typescript 5.3.3
DENO_DIR location: /root/.cache/deno
Remote modules cache: /root/.cache/deno/deps
npm modules cache: /root/.cache/deno/npm
Emitted modules cache: /root/.cache/deno/gen
Language server registries cache: /root/.cache/deno/registries
Origin storage: /root/.cache/deno/location_data
HOSTNAME=658df3116435
YARN_VERSION=1.22.19
PWD=/
HOME=/root
DENO_INSTALL=/root/.deno
SHLVL=1
PATH=/root/.deno/bin:/root/.deno/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
NODE_VERSION=20.11.0
_=/usr/bin/env
==deno===
error: Uncaught (in promise) TypeError: res.socket.getPeerCertificate is not a function
  const cert = res.socket.getPeerCertificate();
                          ^
    at HttpsClientRequest.<anonymous> (file:///$deno$stdin.ts:7:27)
    at Object.onceWrapper (ext:deno_node/_stream.mjs:1931:30)
    at HttpsClientRequest.emit (ext:deno_node/_stream.mjs:1854:9)
    at node:http:516:16
    at eventLoopTick (ext:core/01_core.js:63:7)
==deno+curl===
Expire Date: Fri Oct 18 2024 23:59:59 GMT+0000 (Coordinated Universal Time)

```