Accepting a TLS server connection programmatically
We are going to develop a small tls-server
program that will accept TLS connections, read an HTTP request from the connected TLS client, and send an HTTP response back to the client.
Our program will take three command-line arguments:
- The server port
- The name of the file containing the TLS server keypair
- The name of the file containing the TLS server certificate chain
In our case, the certificate chain file will only contain one certificate – the server certificate. But if we had intermediate CA certificates, we could include them in the file after the server certificate to help the TLS client with the server certificate verification. It does not make much sense to include the root CA certificate in the certificate chain file, because the TLS client must have the root CA certificate among the trusted certificates anyway to be able to verify the server certificate.
Our high-level implementation plan...