Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Node.js honor HPKP/support certificate pinning?

Does Node.js support certificate pinning? More specifically, if a server passes a HPKP header on the first connection, will Node.js honor that setting?

Note that this is for library in which a client connects to my server. I don't care if the HTTPS server in Node supports certificate pinning.

I also understand that I can inspect the certificate manually and there are a few third party libraries which will check on every connection or monkey patch the request library. I'm not asking about that functionality, either.

My plan is to check the certificate the first time and reject if it doesn't match. However, that doesn't do me any good if the TLS cert is changed after that first call.

like image 809
Indolering Avatar asked Feb 26 '26 07:02

Indolering


1 Answers

Use res.socket.getPeerCertificate().fingerprint property of HTTPS response, compare it with your preshared value.

like image 68
zakjan Avatar answered Mar 01 '26 19:03

zakjan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!