Cyllenian

A minimalist HTTPS server that I built to better understand HTTP, SSL, and the POSIX socket API. It proved to be a highly educational way to begin exploring low level networking concepts.

Tech Stack

Category Technology Used
Language C
Compiler GCC
Build System GNU Make
Libraries OpenSSL
Operating System Linux
License GNU General Public License V2

Features

Challenges & Solutions

Testing

The project was tested manually on each build by ensuring the following:

Lessons Learned

HTTP is a text-based protocol, so parsing and constructing headers is simple string manipulation.

The SSL structure and context must be freed in addition to closing the socket file descriptor. Since the user may choose to terminate the program at any point, it was essential to learn how to implement signal handling for SIGINT.

In C, the range of a signed char is -128 to 127 while the range of an unsigned char is 0 to 255 because the former uses the most significant bit for the sign. Binary data can use any value within the 8-bit range, so it is essential to use an unsigned char array when storing binary data in a buffer.

It is easy to run into corruption when trying to send binary data and text together for a variety of reasons, the potential for the data to contain a null byte being chief among them, so sending the HTTP header and body separately is ideal.

Another protocol family supported by the POSIX socket API, PF_UNIX, is widely used on POSIX-like operating systems for inter-process communication.

Future Plans

While I consider the project to be mostly feature complete, I plan to add integration testing and epoll support in the future.

Further Reading

View Source Code on Github