What web developers should know about SSL but probably don't.

In 2015 web developers understand more about SSL than they ever have. If you read Hacker News you should know:

  • You can get domain validated certs from Let's Encrypt for free.
  • You can get EV certs from CertSimple with checks before you pay. That's us by the way!
  • The Mozilla SSL Config Generator can set up your server as secure as possible for the browsers you want to support.
  • When you're done, use SSL Labs to check everything. Make sure you get an A, otherwise people will pick on you.

What about the rest? Here are answers to the most common questions from our customers:

1. Fixing 'obsolete cipher suite' in Chrome

This comes up more than anything else, because it doesn't show up in SSL Labs. If Chrome complains about:

connection is encrypted using an obsolete cipher suite

You need to put GCM ciphers before CBC ciphers in your web server's config file.

This is pretty easy: the Mozilla SSL Config Generator shows the right config for most web servers. Update your config file, restart your web server and the problem will be resolved.

2. Fixing key / certificate mismatches

If you've:

  • Changed your encryption
  • Renewed your certificate
  • Lost your private key and made a new keypair

There's a good chance you have a bunch of files with the same names, belonging to different keypairs. If your web server tells you something like:

Error: Public Key Certificate and Private Key doesn't match

This means you've made multiple key pairs, and are trying to use the private key from one keypair with the certificate from another.

To check whether a certificate file matches a private key, check the modulus.

# Check the modulus of a certificate
openssl x509 -noout -modulus -in example.com.crt | shasum -a 256

# Check the modulus of a key
openssl rsa -noout -modulus -in example.com.key | shasum -a 256

# Check the modulus of a certificate request
openssl req -noout -modulus -in example.com.csr | shasum -a 256

If the modulus is the same, the private key and certificate match: in other words, they belong to the same pair.

If the modulus is different, the files aren't part of the same pair and were created independently.

3. Setting up working SSL on localhost

Use geolocation? WebRTC? Current browsers need SSL for security-sensitive HTML5 features.

If you have an invalid https:// setup on localhost, you'll be spending way too much time clicking clicking through SSL warnings. The good news is you don't need to. Setting up a trusted localhost setup on your Mac only takes a few minutes.

4. You probably don't want a 4096 bit RSA certificate.

1024 bit RSA is considered insecure. Nearly every website you visit uses 2048 bit RSA. So why not go the extra mile and get a 4096 bit RSA cert?

The answer is that the additional load can slow down the SSL handshake between browsers and your site. You can easily measure this in Chrome dev tools.

If you're concerned about strength, try an ECDSA certificate instead of RSA. They're significicantly stronger while using less CPU than RSA - a 256 bit ECC key is equivalent to 3072 bit RSA.

ECC support in 2015 is surprisingly good: browsers from Windows Vista and up, OS X 10.9, Android 3 and iOS 7. The main issue is cloud providers: Heroku and AWS CloudFront don't yet support ECC.

5. How to convert between the common SSL file formats

There's a bunch of file formats related to PKI and SSL, but most server software these days uses just two:

PEM

  • The format used by haproxy, nginx, Apache, node, and everything else that uses openssl.
  • PEM is text based - keys, certificates and CA certificates use the -----BEGIN (TYPE)----- and -----END (TYPE)-----
  • These are typically in separate files, but can also be combined together - either paste them into the same file, or split them into multiple files with a text editor.

PKCS12

  • A binary format used by Windows and Tomcat (in it's default configuration), with the extension .pfx or .p12.
  • Combines the private keys, certificates and intermediary certificates into a single file.

You can flip between them easily:

# Convert PEM to PKCS12
openssl pkcs12 -export -inkey privatekey.pem -in cert.pem -certfile cacert.pem -out bundle.p12

# Convert PKCS12 file to PEM
# (you can then chop the files up with a text editor)
openssl pkcs12 -nodes -in bundle.p12 -out bundle.pem

Source: