undici: Can't Ignore SSL Error ERR_SSL_DH_KEY_TOO_SMALL
Bug Description
I need to request an old website with outdated SSL security leading to an ERR_SSL_DH_KEY_TOO_SMALL error.
I need to ignore this error on this specific request.
- I tried to use
rejectUnauthorized: false
but this is not taken into account - I tried to use
OPENSSL_CONF=someCustom.cnf
env variable and it’s not taken into account either
Reproducible By
import { Agent, setGlobalDispatcher, fetch } from 'undici';
setGlobalDispatcher(new Agent({ connect: { rejectUnauthorized: false, } }))
await fetch('https://www.aerocontact.com/entreprise-aeronautique/societe-latecoere-1128/offres-emploi-aeronautique?')
// This throw with ERR_SSL_DH_KEY_TOO_SMALL
Expected Behavior
I want the ssl error to be ignored when i specify rejectUnauthorized: false
Environment
Node.JS v20.10.0 OpenSSL 3.2.0 EndeavourOS (last)
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 16 (5 by maintainers)
I’m still having some hard times reproducing, most likely might be doing it wrong; though, an
openssl.cnf
example for a customized behaviour should follow a similar format:And should be passed down to
node
using its either flag or the environment variableOPENSSL_CONFIG
. e.g. flagnode --openssl-config /path/to/config script.js
or through env var
OPENSSL_CONF=/path/to/config node script.js
Found the documentation ^^. For those landing on this issue, it’s located here: https://undici.nodejs.org/#/docs/api/Client?id=parameter-connectoptions with a link to this documentation: https://nodejs.org/api/tls.html#tls_tls_connect_options_callback
I confirm this is working fine 🤩 Thank you for your time ! 😃
The solution working for my case:
You can do it by passing the
cipher
property to theAgent
under theconnect
scope, e.g.That should do the work 👍
ah, ok sorry, now I got you 👍 And no, it doesn’t work like that; the
rejectUnauthorized
is meant for CAs, as it will mandate whether or not reject requests whose certificate has a valid CA (avoiding self-signed or similar)Nice, thanks! I was able to reproduce it; Now, lowering the sec level to 1 did the trick for me; did you try it already?
Reference
@metcoder95 i closed this issue a bit too fast. I succeed to reproduce the bug with previous openssl version. Here is how to proceed :
This
openssl.cnf
fileThen
node --openssl-config ./openssl.cnf
and executeThis will throw
ERR_SSL_DH_KEY_TOO_SMALL
.PS : If you get
UND_ERR_CONNECT_TIMEOUT
error, just run the fetch again (this website is really slow)Hi @metcoder95 sry for wrong issue report. I tried with your openssl.cnf format and it’s working fine. I bet i miss-unerstood the tutorials about how to write this file :face_in_clouds: