sindresorhus / ky

🌳 Tiny & elegant JavaScript HTTP client based on the Fetch API
MIT License
11.91k stars 342 forks source link

Support for SSL client certificate in Nodejs undici #549

Closed snird closed 3 weeks ago

snird commented 7 months ago

I know this library is intended for use in browser & nodejs, but one of the strong use cases for using it in node is the massive performance boost the underlying undici has over the http module.

So given the benefit of using a library that utilizes undici, and that ky is currently the best wrapper for a more convenient use - I ask about a specific implementation for nodejs.

Undici can utilize client certificates: https://github.com/nodejs/undici/blob/main/docs/best-practices/client-certificate.md If I'm not mistaken, the implementation on ky side is to allow some way of passing the tls details to the connect method (which is standardized, only the tls parameters aren't)

Is it possible?

sindresorhus commented 7 months ago

ky depends on fetch, which is built on Unidici in Node.js. You will have to get Node.js to expose additional options on fetch for this to be possible. Ky has no access to Unidici through fetch.

sholladay commented 3 weeks ago

I found this example that reportedly works: https://github.com/nodejs/node/issues/48977

From what I can tell, that should work with Ky.

I'm closing this issue as I don't think there is anything for us to do here.