I have a Node.js server that receives a request with the Client TLS certificate supplied in the XFCC header.
I would like to perform the Mutual TLS at the Application level, i.e. validate Client TLS cert against the server's CA truststore - all of this done in application code, rather than relying on a web proxy configuration.
I am using NPM's pem dependency, which is essentially a bunch of JS wrappers around openssl
. In particular, the verification needed to resemble mTLS is the verify
method:
openssl verify -CAfile /my/server/ca-chain.crt client-chain.crt
This works in the simplest case:
- ca-chain.crt:
Root CA
->Int 1 CA
- client-chain.crt
Root CA
->Int 1 CA
->Leaf 1
But it fails in the more complex cases where Int CA's are different:
- ca-chain.crt:
Root CA
->Int 1 CA
- client-chain.crt
Root CA
->Int 2 CA
->Leaf 2
With the following:
openssl verify -CAfile /my/server/ca-chain.crt client-chain.crt
error 20 at 0 depth lookup:unable to get local issuer certificate
As far as I understand mTLS would be successfully performed as long as all certs are valid and lead up to the same Root CA
, despite different Int CA
's, which means verify
doesn't work as-is for the purpose of doing mTLS equivalent at the App level.
I know about s_client
and s_server
capabilities, but they seem like hacks for what I need, rather than a proper solution.
I guess my question is then this:
- Is it possible to use
openssl
to verify certificate against CA chain according to the mTLS rules? - And if not possible, then what would be the way to do it without resorting to writing it from scratch?