Egidi
Egidi

Reputation: 1776

Checking in nodeJS Express if IIS Client Cert Authentication went ok

I have some client machines that connect to my IIS server using client certificate authorization. I have a node.js webapp published on IIS (using iisnode) that receives the requests from the clients.

Is there a way in express to know if the authentication was ok? I know that if the authentication was not ok the http request does not reach to express because it is rejected but I need a field to check if it was ok, because I access the same webapp without ssl and I this particar request only needs to be called if the call was using the client ssl authentication.

I tried with req.socket.authorized but it is undefined and with req.socket.getPeerCertificate(true) I am getting TypeError: req.socket.getPeerCertificate is not a function

Upvotes: 0

Views: 579

Answers (1)

mernstacking
mernstacking

Reputation: 71

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

Upvotes: 1

Related Questions