HTTP/2 with Node.js

Jacob Clark
5 min readFeb 2, 2016

Let’s take a crash course on how we can build HTTP/2 ready applications in Node.js.

Firstly, many clients and browsers are not planning on implementing the ability to use HTTP/2 over plain-text, even though this is in the protocols specification. This notion comes as a wider community effort to move towards a more secure and encrypted internet by default.

For us however, this means if we intend on using HTTP/2 in production, we must supply a valid TLS certificate!

If you wish to use a valid TLS certificate which is signed by an authority and not self signed, I recommend Let’s Encrypt, a free, automated and open certificate authority!

For the purpose of this guide, we’re going to be using self-signed certificates, feel free to replace these steps with a certificate you have acquired from Let’s Encrypt (or another certificate authority).

This is the real nitty gritty stuff of openssl, let’s quickly zip past it and get ourselves a certificate.

This post is a republication of https://blog.jacob.uk.com/http-2-with-node-js/ from my blog https://blog.jacob.uk.com.

Generating a TLS certificate

Create a new project directory and assuming you have openssh installed, lets generate a 2048 bit private key for our server, note that we specify the key passphrase as ‘x’ using the flag ‘-passout pass:x’:

$ mkdir node-http && cd node-http
$ openssl genrsa -des3 -passout…

--

--

Responses (6)