1

Suppose I have 2 Servers (Server A and Server B) that need to communicate with each other and not with anybody else. Can I use Mutual TLS (mTLS) to achieve this? Is mtls a good approach or will I have to handle security at the application layer?

Asking because, what if a third server (Server C) gets a valid certificate from a Trusted CA and tries to communicate with one of the two Servers A or B? Since, most of the root CAs are already trusted by the OS, Server A or B might accept any communication from Server C.

2
  • Typically server TLS certificates require only the usage "server authentication" but the client in a TLS-connections requires a certificate valid for "client authentication". Therefore such a scenario would only work if at least one of the servers has a certificate with both client and server authentication allowed.
    – Robert
    Jul 30, 2021 at 15:00
  • Please have a read on what mTLS is and how it works: cloudflare.com/en-gb/learning/access-management/…
    – schroeder
    Aug 3, 2021 at 9:14

2 Answers 2

2

Yes, you do need to implement application level security. Generally TLS end-points will forward the user certificate of the other party along after authentication of that party. The authentication requires the associated private key of the other party of course, just sending the certificate won't do.

The certificate contains the subject which should contain an identifying feature that you want to accept. For web servers this is often the server address or addresses. CA's should not give out certificates to this address without checking the identity of the requester.

If you would only want to trust one party B you could also just trust the end user certificate of party B (instead of the root or a CA certificate). This is called certificate pinning. It has the disadvantage that any new certificates won't be accepted; for that reason it is generally avoided.


Note that it is of course also possible to setup a separate PKI that only offers certificates to specific parties. Any party outside that select group would not have a certificate under that particular CA, so if that CA's certificate is the only one that is trusted, you'd exclude C.

1

Mutual Authentication TLS, aka using a client authentication certificate, will only authenticate both parties. The machine initiating the connection ("the client") will receive the server identity certificate, and the machine that had the open port ("the server") will receive the client identity certificate.

Restricting access such that each party allows only the other is an authorization decision, which is something you'd have to do at the application layer (or a library layer that's after TLS but before your program). (Even the notion of "trusted" or "expired" is really an authorization decision, but those are usually default policy that a TLS library will/can apply for you.)

what if a third server (Server C) gets a valid certificate from a Trusted CA and tries to communicate with one of the two Servers A or B

From a TLS perspective, it'll work. From a TLS + default policy (not expired, not revoked, chains to a trusted anchor), it'll work. If you applied custom authorization policy to only allow the A or B identity certificates then you would, of course, need to update that (if appropriate).

You must log in to answer this question.