简体   繁体   中英

How to configure a Play application to use Let's Encrypt certificate and to convert let's encrypt certificate so that play can understand it?

I have been using play framework as my server and react webpage as a client. I have already created and set up certificate for react webpage using letsencrypt. But, now i have to configure this certificate work also for play application. How can i configure application.conf to use it?

I myself found answer answer to my Question.

First create certificate for nginx from https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-16-04#step-5-enabling-the-changes-in-nginx

After creating certificate, follow following step:

1) First stop your play server

2) Do sudo su

3) Do ssh and go to the location where your sslcertificate is which will be like: /etc/letsencrypt/live/example.com

4)Type following command

openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out cert_and_key.p12 -CAfile chain.pem -caname root -passout pass:your_password

5)Type following command

keytool -importkeystore -srcstorepass your_password -destkeystore keyStore.jks -srckeystore cert_and_key.p12 -srcstoretype PKCS12 -storepass your_password

6) After .jks is created put following code in your application.conf file:

play.crypto.secret="changethissosomethingsecret"
play.server.https.keyStore.path = "Path to your .jks file"
play.server.https.keyStore.type = "JKS"
play.server.https.keyStore.password = "yourKeyStorePassword"

5) Now change your play run command to following

nohup /home/ubuntu/webserver/manpowercompany-1.0-SNAPSHOT/bin/manpowercompany -J-Xms128M -J-Xmx1024M -Dplay.crypto.secret=anyKey -Dhttps.port=9002 &

Note: Change the directory according to your file locations

6) Start the server with the file containing above run command. You might need to do sudo.

7) You are good to go. Now your server is served as https at port 9002

Above procedure are the step i did according to my project. So, do reference this and make changes according to your project. Thank you!!!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM