Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node js - Get certificate thumbprint using node-forge as cross platform application

I am using node-forge distribution from below link

https://github.com/digitalbazaar/forge-dist/blob/master/dist/forge.min.js

How to get Certificate thumbprint in my application using node-forge as cross platform application. My application is connection to some domain like www.anydomain.com every time it makes ajax call to get the data from the services. I want to read certificate thumbprint to apply some logic.

enter image description here

Please help if anybody have the solution.

like image 891
Himmat Singh Avatar asked Sep 02 '25 09:09

Himmat Singh


1 Answers

It's not really straightforward, but (if your certificate is cert variable):

const md = forge.md.sha1.create();
md.update(forge.asn1.toDer(forge.pki.certificateToAsn1(cert)).getBytes());
const hex = md.digest().toHex();
like image 114
nemisj Avatar answered Sep 05 '25 00:09

nemisj