X

How To Configure SSL For Apache Tomcat 8 Using Let’sencrypt On Ubuntu 19.04

I have to show how to using let’s Encrypt for apache tomcat 8.0.46 and java 8u144. Let’s encrypt is an open source ssl solution for everyone. So I am configure it on Ubuntu 19.04 server.

How To Add Windows Host In Zabbix Server
How To Install FreePBX Server On Ubuntu 14.04

If your server local so below port must be forward from your router.

  • 80 (LAN) point to 80 (WAN) << Not permanent [ only When install Let’s encrypt ]
  • 8443 (LAN) point to 8080 or other what you needed (WAN) << Permanent
  • LAN IP : 10.66.50.20
  • WAN IP : 45.251.231.171
  • JAVA version : 8u144 << Tested
  • Tomcat version : 8.0.46 << Tested

Step #01: Server must be update so not update your server so use this command for update Ubunut 19.04.

root@Apache-Tomcat:~# apt-get update && upgrade -y

Step #02: Install let’s encrypt and certbot for Ubuntu 19.04.

root@Apache-Tomcat:~# add-apt-repository ppa:certbot/certbot
root@Apache-Tomcat:~# apt-get update
root@Apache-Tomcat:~# apt-get install letsencrypt -y
root@Apache-Tomcat:~# wget https://dl.eff.org/certbot-auto -P /usr/local/bin
root@Apache-Tomcat:~# chmod a+x /usr/local/bin/certbot-auto
root@Apache-Tomcat:~# export DOMAIN="tomcat.technologyrss.com"
root@Apache-Tomcat:~# export EMAIL_ALERT="admin@technologyrss.com"

Before install stop tomcat service using below command.

root@Apache-Tomcat:~# /etc/init.d/tomcat stop

Now run main command for install let’s encrypt on my ubuntu server.

root@Apache-Tomcat:~# /usr/local/bin/certbot-auto certonly --standalone -d $DOMAIN  --preferred-challenges http --agree-tos -n -m  $EMAIL_ALERT --keep-until-expiring
root@Apache-Tomcat:~# certbot-auto renew

So now I install p12 file and jks file using java tool and previously created letsencrypt fullchain.pem & privkey.pem

Step #03: Create .p12 file using below command & this file save into /etc/letsencrypt/ location.

root@Apache-Tomcat:~# openssl pkcs12 -export -out /etc/letsencrypt/fullchain.p12 -in /etc/letsencrypt/live/tomcat.technologyrss.com/fullchain.pem -inkey /etc/letsencrypt/live/tomcat.technologyrss.com/privkey.pem -name tomcat

Create two time password for using every time this.

Step #04: Goto my java bin location for create .jks file using fullchain.p12 file.

root@Apache-Tomcat:~# cd /home/app/Java/jdk/8u144/bin/
root@Apache-Tomcat:/home/app/Java/jdk/8u144/bin# ./keytool -importkeystore -deststorepass passw0rd -destkeypass passw0rd -destkeystore /etc/letsencrypt/tomcat.technologyrss.com.jks -srckeystore /etc/letsencrypt/fullchain.p12  -srcstoretype PKCS12 -srcstorepass passw0rd -alias tomcat

Step #05: Open server.xml file from tomcat folder.

root@Apache-Tomcat:~# vi /home/app/Tomcat/8.0.46/conf/server.xml

Inert or edit below all lines into server.xml file.

<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
            maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
            keystoreFile="/etc/letsencrypt/tomcat.technologyrss.com.jks"
            keystorePass="passw0rd"
            clientAuth="false" sslProtocol="TLS" />

Save this file & stop and start tomcat.

root@Apache-Tomcat:~# /etc/init.d/tomcat start

Then browse your server domain using ssl. If any problem so see my YouTube channel for more details. Please subscribe my channel for more update.

0 0 votes
Article Rating
Admin: I am system administrator as Windows and Linux platform. I have 4 years skilled from the professional period. I have to configure Linux based system such as an Asterisk VOIP system, Network monitoring tools (ZABBIX), Virtualization (XEN Server), Cloud computing (Apache CloudStack) etc. Now share my professional skill each interested person. Thanks to all.

View Comments (2)

Leave a Comment