node.js - 如果 IIS 客户端证书身份验证正常,则检查 nodeJS Express

标签 node.js express ssl iis ssl-certificate

我有一些客户端计算机使用客户端证书授权连接到我的 IIS 服务器。我在 IIS 上发布了一个 node.js webapp(使用 iisnode),它接收来自客户端的请求。

有没有办法知道身份验证是否正常?我知道如果身份验证不正确,则 http 请求无法表达,因为它被拒绝了,但我需要一个字段来检查它是否正常,因为我在没有 ssl 的情况下访问同一个 webapp,而我只需要这个 particar 请求如果调用使用客户端 ssl 身份验证,则调用。

我尝试使用 req.socket.authorized 但它是 undefined 并且使用 req.socket.getPeerCertificate(true) 我得到 TypeError: req.socket.getPeerCertificate 不是函数

最佳答案

req.secure

A Boolean property that is true if a TLS connection is established. Equivalent to:

'https' == req.protocol;

http://expressjs.com/en/api.html#req.secure

关于node.js - 如果 IIS 客户端证书身份验证正常,则检查 nodeJS Express,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44268791/

相关文章:

javascript - EventDrops for D3.js(来自 marmelab) - 如何调整示例代码?

node.js - AWS lambda 函数 - 'An error has occurred: Received error response from Lambda: Handled'

node.js - 错误: No default account store is mapped to the specified application

ssl - 如何使用 java -Djavax.net.debug=true 选项启动 Leingen?

ssl - 在证书名称中使用 IP 地址的异常(exception)情况

Node.js:async.map 越来越慢

javascript - node.js 从字符串属性名称设置属性

json - 使用 application/vnd 的 super 测试请求中的正文为空

javascript - Express.js - 在同一页面上发送警报作为响应

php - 经过身份验证的 curl 在 php 中不起作用