help icon indicating copy to clipboard operation
help copied to clipboard

The https.request() make error 'ERR_SSL_UNSUPPORTED_PROTOCOL' with Node V12.2.0

Open kunjiang opened this issue 7 years ago • 9 comments

  • Node.js Version: v12.2.0
  • OS: Win10
  • Scope (install, code, runtime, meta, other?): I download zip, and set environment variable to run, like this: /c/tools/node/node-v12.2.0-win-x64/node app.js

I use request method of module https, and sometimes make error, but not always. The code like this:

// I am an example of JS code
const https = require( 'https' );

let req = https.request( 'https://www.cattelanitalia.com/zh/?', res => {
  console.log( res );
} );

req.on( 'data', d => {
  console.log( '\ndata event trigger: ', d );
} );

req.on( 'error', err => {
  console.log( '\nerror event trigger: ', err );
} );

make error:

error event trigger:  [Error: 12012:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol:c:\ws\deps\openssl\openssl\ssl\statem\statem_lib.c:1922:
] {
  library: 'SSL routines',
  function: 'ssl_choose_client_version',
  reason: 'unsupported protocol',
  code: 'ERR_SSL_UNSUPPORTED_PROTOCOL'
}

But, I ues Node Version v10.15.0, everything is OK. I do not know why, and how to run it in the version v12.2.0.

Thanks very much!

kunjiang avatar May 30 '19 06:05 kunjiang

Your difference in behaviour is probably related to the new default support for TLS 1.3, but also disables TLS 1.0 support at Node 12. That is, if your client and server are not able to agree a protocol and cipher suite in common, then this would be consistent with ssl_choose_client_version:unsupported protocol error. You probably should check that the client end is capable of supporting a TLS 1.2 protocol/cipher.

shellberg avatar May 30 '19 17:05 shellberg

thank you so much. i got it!

kunjiang avatar May 31 '19 00:05 kunjiang

answered, closing

gireeshpunathil avatar Jun 24 '19 08:06 gireeshpunathil

node --tls-min-v1.0 index.js

might help

spidgorny avatar Oct 09 '19 11:10 spidgorny

To change the TLS min version during runtime, you can do:

require('tls').DEFAULT_MIN_VERSION = 'TLSv1'

FreddyFY avatar Dec 13 '19 15:12 FreddyFY

To change the TLS min version during runtime, you can do: require('tls').DEFAULT_MIN_VERSION = 'TLSv1'

Thanks, this works for me ! You saved my day :)

I just had the same issue with Node v12.13.1 and the Fetch API (using the node-fetch module). See error stack below:

FetchError: request to https://whatever_url failed, reason: write EPROTO 139716447246144:error:1425F102:S
SL routines:ssl_choose_client_version:unsupported protocol:../deps/openssl/openssl/ssl/statem/statem_lib.c:1929:
at ClientRequest.<anonymous> (./node_modules/node-fetch/lib/index.js:1455:11)
at ClientRequest.emit (events.js:210:5)
at TLSSocket.socketErrorListener (_http_client.js:406:9)
at TLSSocket.emit (events.js:210:5)
at errorOrDestroy (internal/streams/destroy.js:108:12)
at onwriteError (_stream_writable.js:452:5)
at onwrite (_stream_writable.js:473:5)
at internal/streams/destroy.js:50:7
at TLSSocket.Socket._destroy (net.js:664:5)
at TLSSocket.destroy (internal/streams/destroy.js:38:8)

Simply adding require('tls').DEFAULT_MIN_VERSION = 'TLSv1'; fixes it !

xprudhomme avatar Dec 27 '19 08:12 xprudhomme

To change the TLS min version during runtime, you can do:

require('tls').DEFAULT_MIN_VERSION = 'TLSv1'

Thanks a lot,This works for me too.

TrumpDk avatar Jul 09 '20 01:07 TrumpDk

To change the TLS min version during runtime, you can do:

require('tls').DEFAULT_MIN_VERSION = 'TLSv1'

Thanks a lot

785085961 avatar Nov 19 '20 09:11 785085961

Thank you

AnilSachinPe avatar Apr 12 '21 04:04 AnilSachinPe