Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play framework with SSL certificates from let's encrypt

I'm trying to work out how to use the certificates I got from let's encrypt with my standalone play application. I turned off my server and ran certbot which generated 4 files (cert.pem,chain.pem,fullchain.pem,privatekey.pem) but I don't know how to get my play application to use these.

I'm using version 2.5.4 of the play framework.

like image 425
skorulis Avatar asked Jul 28 '16 07:07

skorulis


1 Answers

Play uses Java key stores to configure SSL certificates and keys.

So you have to do this:

  1. Convert your Let's encrypt certificates to PKCS12
  2. Convert PKCS12 to Keystore
  3. Configure Play to use the keystore

1. Cert and Key to a PKCS12 file

openssl pkcs12 -export -in server.crt -inkey server.key \
    -out server.p12 -name [some-alias] \
    -CAfile ca.crt -caname root

2. Convert PKCS12 to Keystore

keytool -importkeystore \
    -deststorepass [changeit] -destkeypass [changeit] -destkeystore server.keystore \
    -srckeystore server.p12 -srcstoretype PKCS12 -srcstorepass some-password \
    -alias [some-alias]

3. Configure Play to use the keystore

/path/to/your/app/app_name_script -Dhttps.port=443 -Dplay.server.https.keyStore.path=[keyStore-location] -Dplay.server.https.keyStore.password=[keyStore-password]
like image 149
Anton Avatar answered Oct 18 '22 11:10

Anton