One line HTTPS server

To avoid the following chrome error:
Server has a weak ephemeral Diffie-Hellman public key
You need to provide a set of ciphers that are strong enough to satisfy chrome requirements, e.g.:

 -cipher kRSA+RSA 

The following works for me:

openssl req -x509 -newkey rsa:4096 -nodes -sha256 -keyout key.pem -out cert.pem -days 365
openssl s_server -key key.pem -cert cert.pem -accept 443 -cipher kRSA+RSA

Ruby WEBrick documentation has a section on HTTPS. I needed to add DocumentRoot and .start and arrived at this:

ruby -r webrick/https -e '
  WEBrick::HTTPServer.new(
    Port: 8000, DocumentRoot: ".",
    SSLEnable: true, SSLCertName: [%w[CN localhost]]).start'

I tested with Ruby 2.1.2.


Browsersync does this well.

Install with

npm i -g browser-sync

Serve the contents of the current directory with

browser-sync start -s --https

No setup required. See the docs for other features.


Hunchentoot could be used for this purpose. The one line is rather long, but not impossibly so. You will need to provide the certificate and key from files, though.

sbcl --eval '(progn
  (and nil #.(require "hunchentoot")) 
  (setq hunchentoot:*dispatch-table* 
        (list (hunchentoot:create-folder-dispatcher-and-handler "/" "'`pwd`/'"))) 
  (hunchentoot:start (make-instance (quote hunchentoot:easy-ssl-acceptor) 
                                    :port 8443
                                    :ssl-privatekey-file "../cert.key"
                                    :ssl-certificate-file "../cert.crt")))'

The command above has been split on multiple lines for readability; it can be entered as a single line as well.

Tags:

Http

Https