This is a conceptual guide on how to setup TLS authentication between server and client(s). The steps are closely based on this Docker guide, but with a focus on the process rather than the technical details, which are more than covered in the linked guide.
The steps, unless specified otherwise should be undertaken on the server/host to which you want to authenticate connections to (in the case above, the Docker host).
The terms key and private key are used interchangeably in this document; the term certificate refers to a public key (X.509).
Certificate Authority (CA) Setup
- Generate a private key that will be used to self-sign the root certificate for the CA.
- Create a self-signed root certificate (public key) which will be used in the CA role to authenticate other keys.
Server Certificates
- Generate a private key for the host you’re on.
- Create a certificate signing request (CSR) based on the host’s private key.
- Resolve the CSR and generate server certificate (sign server key wth root certificate).
Client Certificates
- Generate a private key for a client from which you wish to connect to the host from.
- Create a CSR based on the client’s private key.
- Resolve the CSR and generate client certificate (sign client key wth root certificate).
Final Steps
- Clear down any remnant CSR files and configs.
- Change key and certificate file permissions (
chmod
0400
and0444
, respectively). - Copy the following certificates to client machine:
- CA certificate
- server certificate
- client certificate
#tls #openssl #security