How to configure a Play application to use Let's Encrypt certificate?

后端 未结 3 1712
离开以前
离开以前 2020-12-30 09:54

Once I obtain the certificate, how do I generate a JKS key store from it?

How do I configure the Play application to use this key store?

Anything else I need

3条回答
  •  庸人自扰
    2020-12-30 10:25

    I recently had to do this, here's my file:

    #!/usr/bin/env bash
    
    sudo killall java #stop the application gracefully
    
    rm -rf /etc/letsencrypt.bak
    
    cp -r /etc/letsencrypt /etc/letsencrypt.bak
    
    certbot renew --standalone
    
    cd /etc/letsencrypt/live/example.com/
    
    openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out cert_and_key.p12 -CAfile chain.pem -caname root -passout pass:your_password
    
    keytool -importkeystore -srcstorepass your_password -destkeystore keyStore.jks -srckeystore cert_and_key.p12 -srcstoretype PKCS12 -storepass your_password
    

    After this, you'll need to set the properties when running the app using the same format as the accepted answer:

    sudo /path/to/app -Dhttp.port=80 -Dhttps.port=443 -Dplay.server.https.keyStore.path=/etc/letsencrypt/live/api.ali.actor/keyStore.jks -Dplay.server.https.keyStore.password=your_password -Djdk.tls.ephemeralDHKeySize=2048 -Djdk.tls.rejectClientInitiatedRenegotiation=true
    

提交回复
热议问题