Tomcat Ssl Letsencrypt

Posted : admin On 1/25/2022

#SSL #Certificate #LetsEncryptLet's Encrypt SSL certificate on tomcatLet’s Encrypt is a free, automated, and open Certificate Authority.To enable HTTPS on yo. Reference book: blog: tomcat keystoreCreate the Keystore keytool -genkey -alias tomca. To install Wamp 64 bits, you can download it from Start tomcat with JPDASUSPEND=y, attach with jdb, then: use stop at, run, print keyPass, print keystorePass – csutherl Apr 29 '16 at 17:11 If those passwords are correct and do actually gain access to the keystore/key, then I think you might be hitting a bug lower than tomcat in sun. Let's Encrypt is a SSL certificate providers free, automatically and operating for the community's benefits. It is managed by Internet Security Research Group (ISRG).

This tutorial is about how to get Apache Tomcat with APR secured with free 'A' grade SSL as per Qualys ssllabs test. It should not take you more than 5 minutes in a clean Centos 7 VPS.

In this copy and paste tutorial we will use CentOS Linux release 7.4.1708 (minimal install) with public IP, Apache Tomcat 8.0.48, Oracle JDK 1.8.0_161 and FQDN hostname resolvable to your server's public IP.

First make sure we use latest software

Secure the host with firewall

Open only ports 80, 443 and SSH port of your choice.

Install Tomcat and JDK

Tomcat will run under regular user and use privileged ports 80 and 443. Another option would be to redirect ports 80 and 443 to default Tomcat ports 8080 and 8443 with iptables. In this tutorial we use Linux capabilities to allow for binding to low ports.

Install APR library for Tomcat (tomcat-native)

APR can be used with both HTTP and HTTPS connectors.

Allow Java to bind privileged ports (<1024) instead of using port forwarding or high (default) ports

Get free Letsencrypt certificate for use with the Tomcat

Update your contact email below.

You should get 'Congratulations! Your certificate and chain have been saved at: PATH TO YOUR PEMS' message.

Install haveged to provide more entropy for SSL routines

Expect 99-1000 sucesses. Without haveged Tomcat bootup was taking a 200 seconds. With haveged it now takes 0.5 sec.

Setup HTTPS APR connector in Tomcat's server.xml

We will change default HTTP port 8080 to 80 as well as insert Connector with port 443.

Insert the following uncommented Connector nearby existing (commented out by default) Connector for HTTPS.


Copy your certificates so that they are readable by Tomcat.

Start Tomcat and verify its startup result

Qualys SSLLabs verification

The test was performed on Feb 1, 2018. Things could change since then.

Tomcat Ssl Letsencrypt

Tomcat 8 Ssl Letsencrypt

Last updated: See all Documentation

Sometimes people want to get a certificate for the hostname “localhost”, eitherfor use in local development, or for distribution with a native application thatneeds to communicate with a web application. Let’s Encrypt can’t providecertificates for “localhost” because nobody uniquely owns it, and it’s notrooted in a top level domain like “.com” or “.net”. It’s possible toset up your own domain name that happens to resolve to, and get acertificate for it using the DNS challenge. However, this is generally a badidea and there are better options.

If you’re developing a web app, it’s useful to run a local web server likeApache or Nginx, and access it via http://localhost:8000/ in your web browser.However, web browsers behave in subtly different ways on HTTP vs HTTPS pages.The main difference: On an HTTPS page, any requests to load JavaScript from anHTTP URL will be blocked. So if you’re developing locally using HTTP, you mightadd a script tag that works fine on your development machine, but breaks whenyou deploy to your HTTPS production site. To catch this kind of problem, it’suseful to set up HTTPS on your local web server. However, you don’t want to seecertificate warnings all the time. How do you get the green lock locally?

The best option: Generate your own certificate, either self-signed or signed bya local root, and trust it in your operating system’s trust store. Then use thatcertificate in your local web server. See below for details.

Sometimes developers want to offer a downloadable native app that can beused alongside a web site to offer extra features. For instance, the Dropboxand Spotify desktop apps scan for files from across your machine, which aweb app would not be allowed to do. One common approach is for these nativeapps to offer a web service on localhost, and have the web app make requeststo it via XMLHTTPRequest (XHR) or WebSockets. The web app almost always uses HTTPS, whichmeans that browsers will forbid it from making XHR or WebSockets requeststo non-secure URLs. This is called Mixed Content Blocking. To communicate withthe web app, the native app needs to provide a secure web service.

Fortunately, modern browsers considerhttp:// to be a“potentially trustworthy”URL because it refers to a loopback address. Traffic sent to is guaranteednot to leave your machine, and so is considered automatically secure againstnetwork interception. That means if your web app is HTTPS, and you offer anative app web service on, the two can happily communicate via XHR.Unfortunately, localhost doesn’t yet get the same treatment.Also, WebSockets don’t get this treatment for either name.

You might be tempted to work around these limitations by setting upa domain name in the global DNS that happens to resolve to instance,, getting a certificate for thatdomain name, shipping that certificate and corresponding private keywith your native app, and telling your web app tocommunicate with instead of’t do this. It will put your users at risk, and your certificate may get revoked.

By introducing a domain name instead of an IP address, you make it possible foran attacker to Man in the Middle (MitM) the DNS lookup and inject a response thatpoints to a different IP address. The attacker can then pretend to be the localapp and send fake responses back to the web app, which may compromise youraccount on the web app side, depending on how it is designed.

The successful MitM in this situation is possible because in order to make itwork, you had to ship the private key to your certificate with your native app.That means that anybody who downloads your native app gets a copy ofthe private key, including the attacker. This is considered a compromise of yourprivate key, and your Certificate Authority (CA) is required to revoke yourcertificate if they become aware of it. Many native apps have had theircertificates revoked for shipping their private key.

Unfortunately, this leaves native apps without a lot of good, secure options tocommunicate with their corresponding web site. And the situation may gettrickier in the future if browsers further tighten access to localhost from theweb.

Also note that exporting a web service that offers privileged native APIs isinherently risky, because web sites that you didn’t intend to authorize mayaccess them. If you go down this route, make sure to read up on Cross-OriginResource Sharing, use Access-Control-Allow-Origin, and make sure to use amemory-safe HTTP parser, because even origins you don’t allow access to can sendpreflight requests, which may be able to exploit bugs in your parser.

Tomcat Ssl Let's Encryption

Anyone can make their own certificates without help from a CA. The onlydifference is that certificates you make yourself won’t be trusted by anyoneelse. For local development, that’s fine.

The simplest way to generate a private key and self-signed certificate forlocalhost is with this openssl command:

You can then configure your local web server with localhost.crt andlocalhost.key, and install localhost.crt in your list of locally trusted roots.

If you want a little more realism in your development certificates, you can useminica to generate your own local root certificate, and issueend-entity (aka leaf) certificates signed by it. You would then import the rootcertificate rather than a self-signed end-entity certificate.

You can also choose to use a domain with dots in it, like www.localhost, byadding it to /etc/hosts as an alias to This subtly changes howbrowsers handle cookie storage.