uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.64k stars 560 forks source link

feat: expose client's peer certificate der data #1062

Open cruz3rblade opened 1 month ago

cruz3rblade commented 1 month ago

This PR implements #1058 and adds access to the client's peer DER certificate data. The function returns an object with a "raw" field in it. So if anyone else wants to expand the information returned about the certificate in the future, they can simply append a new key to the object.

Note: I'm not super familiar with C++, so I hope I got everything right. Please go easy on me with the review 😅

uNetworkingAB commented 1 month ago

This looks good as an early variant, but ideally it would be handled entirely by the library without any Node.js features or copies of data. But for an early draft of the feature, this looks good.

cruz3rblade commented 1 month ago

Thank you for your feedback. How would you like to proceed with this? Are we good to merge this one, or should I implement this logic at the library level?

uNetworkingAB commented 1 month ago

You have the code formatting of a psychopath but that's fine. This is fine as a first step until more thought can be made. This API can break in future releases.

cruz3rblade commented 1 month ago

I have made a few changes and removed the NodeJS copies. Also, If you prefer I can move extractX509PemCertificate method to the C++ library and expose it in HttpResponse so all the wrapper has to do is call res->getX509Certificate()