How can I set up a letsencrypt SSL certificate and use it in a Spring Boot application?

前端 未结 7 2072
长情又很酷
长情又很酷 2020-12-07 09:14

I\'m new to securing a server so I don\'t really know much about this but I need to get my Spring Boot Application that is running on a Digital Ocean Droplet to use HTTPS. <

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-07 09:52

    Step 1: Download certbot from git

    You need to fetch the source code of Let's Encrypt on your server which your domain address is pointing to. This step may take a couple minutes.

    $ git clone https://github.com/certbot/certbot

    $ cd certbot

    $ ./certbot-auto --help

    Remark: Python 2.7.8 (or above) should be installed beforehand.

    Step2: generates certificates and a private key

    By executing following command in your terminal, Let's Encrypt generates certificates and a private key for you.

    $ ./certbot-auto certonly -a standalone \

    -d example.com -d example.com
    

    Remark:Keys are generated in /etc/letsencrypt/live/example.com directory

    Step3: Generate PKCS12 Files From PEM Files

    To convert the PEM files to PKCS12 version: Go to /etc/letsencrypt/live/example.com convert the keys to PKCS12 using OpenSSL in the terminal as follows.

    $ openssl pkcs12 -export -in fullchain.pem \

           -inkey privkey.pem \
    
               -out keystore.p12 \
    
           -name tomcat \
    
           -CAfile chain.pem \
    
           -caname root
    

    Enter Export Password:

    Verifying - Enter Export Password:

    (Note:- Write single line at a time and press enter)

    Step4: Configuration of Spring Boot Application

    Open your 'application.properties' Put this configuration there.

    server.port=8443 security.require-ssl=true

    server.ssl.key-store=/etc/letsencrypt/live/example.com/keystore.p12

    server.ssl.key-store-password= password

    server.ssl.keyStoreType= PKCS12

    server.ssl.keyAlias= tomcat

提交回复
热议问题