The https.request() make error 'ERR_SSL_UNSUPPORTED_PROTOCOL' with Node V12.2.0
- 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!
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.
thank you so much. i got it!
answered, closing
node --tls-min-v1.0 index.js
might help
To change the TLS min version during runtime, you can do:
require('tls').DEFAULT_MIN_VERSION = 'TLSv1'
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 !
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.
To change the TLS min version during runtime, you can do:
require('tls').DEFAULT_MIN_VERSION = 'TLSv1'
Thanks a lot
Thank you