OpenSSL.md 3.2 KB

Adding OpenSSL Support

Civetweb supports HTTPS connections using the OpenSSL transport layer security (TLS) library. OpenSSL is a free, open source library (see http://www.openssl.org/).

Getting Started

  • Install OpenSSL on your system. There are OpenSSL install packages for all major Linux distributions as well as a setup for Windows.
  • The default build configuration of the civetweb web server will load the required OpenSSL libraries, if a HTTPS certificate has been configured.

Civetweb Configuration

The configuration file should contain an https port, e.g. listening_ports 80, 443s to server http and https from their standard ports, or
listening_ports 443s to serve only https.

Furthermore the SSL certificate file must be set, e.g. ssl_certificate d:\civetweb\certificate\server.pem

Creating a self signed certificate

OpenSSL provides a command line interface, that can be used to create the certificate file required by civetweb (server.pem).

One can use the following steps in Windows (in Linux replace "copy" by "cp" and "type" by "cat"):

openssl genrsa -des3 -out server.key 1024

openssl req -new -key server.key -out server.csr

copy server.key server.key.orig

openssl rsa -in server.key.orig -out server.key

openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt

copy server.crt server.pem

type server.key >> server.pem

The server.pem should look like this (x represents BASE64 encoded data):

-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx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