How can i install letsencrypt ssl on java app

Hi I want to install letsencryption ssl on java app linux server.

I have hosted java app on linux server. now i want to protect this app via lets encryption,

can any one help me to do this


How are you running it? Spring Boot jar or in a servlet container (like Tomcat)?

using spring boot jar

You’re going to need to install another server to handle SSL for you, as a reverse proxy.

For example, install nginx (apt install nginx or yum install nginx depending which Linux distribution), and setup a virtual host like this:

server {
        listen 80;
        listen [::]:80;

        location / {
                proxy_set_header Host      $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;

Change your Spring Boot to use a different port and understand the headers:


Stop your Java application, start nginx, start your Java application.

Then, download Certbot using the instructions on this site:

and then run:

certbot --nginx -d

and it will create and configure a certificate for you.

can we do this using apache, with our negix?


You can use Apache httpd if you want, but you’ll have to figure out the instructions by searching online.

Tomcat is embeded into Springboot

so its actually Tomcat running as webserver

Springboot is a framework for backend coding

I am not want to run proxy server can you give me solution for this,

The reason that I suggested a reverse proxy is that it is a simple solution that integrates with the Let’s Encrypt ecosystem, with automatic renewal.

If you want your Spring Boot jar to handle SSL for you, you are welcome to issue a certificate manually and configure your with the required server.ssl configuration parameters … and repeat that task every 60-90 days.

If i want ssl certificate with spring boot jar then i need to use open ssl?

how can i issue certificate manually???

You can stop your Spring Boot app and use:

certbot certonly --standalone -d

or you can keep your app running and use DNS validation:

certbot certonly -a manual --preferred-challenges dns -d

Once you do this, you will need to convert the certificates into the correct format for the embedded Tomcat server:

openssl pkcs12 -export -out /etc/letsencrypt/live/ -inkey /etc/letsencrypt/live/ -in /etc/letsencrypt/live/ -certfile /etc/letsencrypt/live/ -password pass:apassword

and then configure with:


Keep in mind the default Spring Boot jar is only capable of doing either HTTP or HTTPS, not both at the same time. If you need anything more complicated, then you need to either stop using the embedded Tomcat server, or inject a new Tomcat connector from Java code.

1 Like

[root@ip-172-31-17-177 letsencrypt]# certbot certonly --standalone -d
bash: certbot: command not found
[root@ip-172-31-17-177 letsencrypt]#

facing this issue

Re-read my earlier posts. I included a link to the Certbot website, which gives you installation instructions.

1 Like

i have done this but application is not coming online,

Why we are using server.port=8443?

before ssl i am using port 80

The application came up:

You can set it to port 443 and then you would be able to visit just .

But as I mentioned, only one port can be used at a time in a Spring Boot jar.

So if you have SSL enabled on port 443, port 80 will not work.

1 Like

A post was split to a new topic: Using Letsencrypt with a java spring-boot application

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.