Included in this chapter's code repository is https_server.c. This program is a modification of web_server.c from Chapter 7, Building a Simple Web Server. It can be used to serve a simple static website over HTTPS.
In the https_server.c program, the basic TLS/SSL connection is set up and established the same way as shown in tls_time_server.c. Once the secure connection is established, the connection is simply treated as HTTP.
https_server is compiled using the same technique as for tls_time_server. The following screenshot shows how to compile and run https_server:
Once https_server is running, you can connect to it by navigating your web browser to https://127.0.0.1:8080. You will likely need to add a security exception when connecting for the first time. The code is set up to serve the static pages from the chap07 directory.
The following screenshot was taken of a web browser connected to https_server:
This chapter's example programs illustrate the basics of HTTPS servers. However, implementing a genuinely robust HTTPS server does involve additional challenges. Let's consider some of these now.