node.js v17 이상부터 openssl 3.0 이 포함되어 구버전 TLSv1.0 을 사용하는 서버에 https 요청시 에러가 발생하는데 이런저런 옵션을 조합해봐도 아래와 같은 에러들이 발생함.
(node.js v22 기준)
Problem with request: write EPROTO 404F9AFC01000000:error:0A000102:SSL routines:ssl_choose_client_version:unsupported protocol:../deps/openssl/openssl/ssl/statem/statem_lib.c:1992:
Problem with request: write EPROTO 404F9AFC01000000:error:0A000152:SSL routines:final_renegotiate:unsafe legacy renegotiation disabled:../deps/openssl/openssl/ssl/statem/extensions.c:922:
Problem with request: write EPROTO 404F9AFC01000000:error:0A00014D:SSL routines:tls_process_key_exchange:legacy sigalg disallowed or unsupported:../deps/openssl/openssl/ss
l/statem/statem_clnt.c:2263:
최적의 조합은 아래와 같음.
const options = {
// openssl의 TLS method 사용 (TLS 1.0/1.1/1.2/1.3 다 포함) TLSv1_method로 지정해도 됨
secureProtocol: 'TLS_method',
// openssl 보안수준을 최하 단계로
ciphers: 'DEFAULT:@SECLEVEL=0',
// legacy TLS 서버 연결 허용
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT
};
이렇게 요청하면 됨.
const https = require('node:https');
const crypto = require('node:crypto');
const options = {
secureProtocol: 'TLS_method',
ciphers: 'DEFAULT:@SECLEVEL=0',
secureOptions: crypto.constants.SSL_OP_LEGACY_SERVER_CONNECT
};
const req = https.request('https://TLSv1.0서버', options, (res)=>{
const chunks = [];
res.on('data', (chunk)=>{
chunks.push(chunk);
});
res.on('end', ()=>{
const body = Buffer.concat(chunks);
console.log(`BODY = ${body}`);
});
});
res.end();
[참고]
https://nodejs.org/en/blog/release/v17.0.0#openssl-30
'node.js' 카테고리의 다른 글
[node.js] WriteStream 사용시 fd close (0) | 2021.07.12 |
---|---|
[node.js] http/https로 application/x-www-form-urlencoded POST로 request (0) | 2021.06.03 |
[node.js] MongoDB find/aggregate 대량 document 가져올 때 MongoNetworkError: cursor killed or timed out 발생시 (0) | 2020.05.27 |
[node.js] load average throttle (0) | 2019.09.26 |
[node.js] 동시에 실행되는 수를 조절하며 비동기 함수 전체 실행 (Promise.all with limited concurrency) (0) | 2019.09.26 |