Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kunjiang opened this issue May 30, 2019 · 9 comments

Comments

@kunjiang
Copy link

  • 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!

@shellberg
Copy link

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.

@kunjiang
Copy link
Author

thank you so much. i got it!

@gireeshpunathil
Copy link
Member

answered, closing

@spidgorny
Copy link

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

might help

@FreddyFY
Copy link

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

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

@xprudhomme
Copy link

xprudhomme commented Dec 27, 2019

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 !

MauricioRobayo added a commit to MauricioRobayo/cambio that referenced this issue Jan 23, 2020
@TrumpDk
Copy link

TrumpDk commented Jul 9, 2020

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.

@785085961
Copy link

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

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

Thanks a lot

@AnilSachinPe
Copy link

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants