Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/smondet/cohttps-server-example

Short code example of an HTTPS server using Cohttp/Lwt-ssl
https://github.com/smondet/cohttps-server-example

Last synced: 16 days ago
JSON representation

Short code example of an HTTPS server using Cohttp/Lwt-ssl

Awesome Lists containing this project

README

        

Quick Example Code
==================

This is a *minimalistic* piece of code showing the creation of an HTTPS server
using `cohttp.lwt` and `lwt.ssl`.

There is not really any error management or parametrization to keep the code
short.

It is ISC licensed, copy at will.

Build & Run
-----------

Compile like this:

ocamlfind ocamlc -package lwt.ssl,cohttp.lwt -linkpkg cohttps.ml -o dummyserver

Create an OpenSSL self-signed certificate:

openssl genrsa -des3 -out privkey.pem 1024
openssl req -new -x509 -days 1001 -key privkey.pem -out cert.pem
openssl rsa -in privkey.pem -out privkey-unsec.pem

Test:

./dummyserver

Both HTTP and HTTPS servers are created; go to or
, it should display some HTML.

Other Notes
-----------

### Using `TLSv1` instead of `SSLv23`

With `Ssl.TLSv1` and *Wget 1.10.2*, I need `--secure-protocol=TLSv1`:

wget --no-check-certificate --secure-protocol=TLSv1 https://:8081

with Wget 1.14, I don't:

wget --no-check-certificate https://:8081

Firefox works without problem.

Ocsigenserver uses `SSLv23` (c.f.
[`ocsigen_http_client.ml:88`](https://github.com/ocsigen/ocsigenserver/blob/master/src/server/ocsigen_http_client.ml#L88)).