简体   繁体   English

从NodeJS中的服务器端证书获取服务器的DN

[英]Getting server's DN from server-side certs in NodeJS

I am running a NodeJS https webserver on an intranet, which makes calls to other secured webservers using REST. 我正在Intranet上运行NodeJS https Web服务器,该服务器使用REST调用其他受保护的Web服务器。 Because one of the sites I need to communicate with requires the server's DN to be appended to the proxied entities/issuers chain when communicating with it, I need to get the Distinguished Name (DN) of the server from its certificates. 因为我需要与之通信的站点之一要求在与之通信时将服务器的DN附加到代理实体/发布者链上,所以我需要从其证书中获取服务器的专有名称(DN)。

I know that normally this is handled behind the scenes by the https.get() call, but is there a way to get the DN before making the get() call? 我知道通常这是通过https.get()调用在后台处理的,但是在进行get()调用之前有没有办法获取DN?

Edward, 爱德华

You can load the certificate directly using PKIjs ( https://pkijs.org ) and then decode the certificate extracting the DN. 您可以使用PKIjs( https://pkijs.org )直接加载证书,然后解码证书以提取DN。

You can see an example of decoding the certificate with this library here - https://pkijs.org/examples/X509_cert_complex_example.html 您可以在此处查看使用此库解码证书的示例-https: //pkijs.org/examples/X509_cert_complex_example.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM