title: Node.js SSL error: wrong version number: ../deps/openssl/openssl/ssl/record/ssl3_record.c:332
body: <p>Using Node.js and cross-fetch, I receive an error accessing an HTTPS site (see title and comments below). There is no proxy involved. The code below is a simplified version that reproduces the error. The comments in the code contain the exact error text.</p>
  <p>This had been working until something (?) changed, which leads me to believe a server-side change, which I have no access to. However, Tampermonkey JS scripts that do the same requests using GM_xmlhttpRequest still work correctly.</p>
  <p>Any debugging suggestions, or why the &quot;wrong version number&quot; is generated?</p>
  <p>Edit: looking in the debugger at the call to <code>tlssock.connect(options, tlssock._start);</code> the 'ciphers' option is set to <code>ciphers: &quot;TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384:DHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA256:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!SRP:!CAMELLIA&quot; </code> and the 'port' option is 443. In the TLSSocket member, I didn't see anything that jumped out at me relating to a version number.</p>
  <pre><code>const fetch = require('cross-fetch');
  const testURL = 'https://api.torn.com/faction/?selections=upgrades&amp;key=xxxxxxxxxx';
  
  fetch(testURL).then(res =&gt; {
      console.log('[TEST] res: ', res);
  }).then(data =&gt; {
      console.log('[TEST] data: ', data);
  }).catch(err =&gt; {
      console.error(&quot;[TEST] error: &quot;, err);
  });
  
  /*
  Output:
  [TEST] error:  FetchError: request to https://api.torn.com/faction/?selections=upgrades&amp;key=xxxxxxxxxx failed, 
                 reason: write EPROTO 140735681590144:
                 error:1408F10B:SSL routines:ssl3_get_record:
                 wrong version number:../deps/openssl/openssl/ssl/record/ssl3_record.c:332:
  
      at ClientRequest.&lt;anonymous&gt; (/Users/edlau/Documents/Torn-JS/Fac-chat-generic/node_modules/node-fetch/lib/index.js:1461:11)
      at ClientRequest.emit (events.js:400:28)
      at TLSSocket.socketErrorListener (_http_client.js:475:9)
      at TLSSocket.emit (events.js:400:28)
      at emitErrorNT (internal/streams/destroy.js:106:8)
      at emitErrorCloseNT (internal/streams/destroy.js:74:3)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    type: 'system',
    errno: 'EPROTO',
    code: 'EPROTO'
  }*/
  </code></pre>
  <p>Edit 2: I updated node.js to the latest, with the same results, versioning info is as follows:</p>
  <pre><code>npm version
  {
    facchat: '2.0.0',
    npm: '8.3.0',
    node: '17.3.0',
    v8: '9.6.180.15-node.12',
    uv: '1.42.0',
    zlib: '1.2.11',
    brotli: '1.0.9',
    ares: '1.18.1',
    modules: '102',
    nghttp2: '1.45.1',
    napi: '8',
    llhttp: '6.0.4',
    openssl: '3.0.1+quic',
    cldr: '40.0',
    icu: '70.1',
    tz: '2021a3',
    unicode: '14.0',
    ngtcp2: '0.1.0-DEV',
    nghttp3: '0.1.0-DEV'
  }
  </code></pre>
  <p>Edit 3: Using CURL (to the same URL):
  curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol</p>