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

 

 

 

Posted by bloodguy
,