Certbot and Tomcat - Certificates Obtained but Not Converted to JKS and Configured with Tomcat (FIXED!)

yes, tomcat restarted

I tried running another command I found here on the forum, didn’t seem to help. Can’t remember what it was now… did not seem to help

Are you using /etc/letsencrypt/live/gpsowl.com/ in your Tomcat config? If you paste the TLS-related portions of your config here, we can see what certificate file your server is configured to use. You might be referencing the certificate files in /etc/letsencrypt/archive by mistake.

1 Like
<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true" URIEncoding="UTF-8"
           clientAuth="false" sslProtocol="TLS" />

It turns out that the files in live are linked to the archive, but I don’t know why. Also, the folders were readonly by root.

I’m getting this error now:

20-May-2017 21:30:26.462 SEVERE [main] org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler [“http-nio-8443”]
java.io.IOException: Invalid keystore format

"/etc/letsencrypt/live/fullchain.pem" or "/etc/letsencrypt/live/gpsowl.com/fullchain.pem"? The former doesn't exist.

Fixed the path; still getting Invalid keystore format

I added a new key (-0001) and the date on the file is a couple days ago. https://www.digicert.com/help/ says it is still expired. Don’t know what to do next.

Could you run

ls /etc/letsencrypt/live

and also

openssl x509 -in /etc/letsencrypt/live/gpsowl.com-0001/cert.pem -text -noout


Is it possible that you converted and imported things from /etc/letsencrypt into that avox.jks some time ago? If so, maybe your old certificate is still stored and represented within that file in some way, and then the conversion and import process would need to be repeated in connection with the certificate renewal?

Also, is there any possibility that you have another web server or reverse proxy such as an Apache, nginx, squid, or similar instance that’s actually listening directly on port 443 and then forwarding requests through to Tomcat? If so, maybe your old certificate is hard-coded in the configuration for the reverse proxy, or maybe it also needs to be restarted.

Hi @gerryscat

The fact that you were using a PEM as the keystore files makes me suspect you don’t quite understand how Java Key Stores Work

There is a fairly detailed walk through here: Using LetsEncrypt Certificates on Tomcat 8.x on Windows

Generally it’s a good idea to answer all the questions in the help section as it helps narrow down the root cause

I suspect this is what has happend

A) You have issued a new certificate for your domain (cannot verify this without your domain name)
B) Certbot has created the key and certificate in the usual location
C) You have not created the keystore out of those certificates in b
D) You have not applied your keystore to Tomcat
E) You have not restarted your tomcat. As such it’s still using the old key store with your old certificate


Hello @gerryscat,

renew command will renew your cert but won't install it in your keystore, you need to do it manually or you can automate it in the renew process but you should provide a script to perform the needed steps to recreate your keystore with the new cert and reload your tomcat.

You are using Nio Protocol so you can't use this directive SSLCertificateFile, this is only valid for APR Protocol.

First you need to renew your cert but you already did, the problem here is that you have generated several certs

CRT ID     DOMAIN (CN)  VALID FROM              VALID TO                EXPIRES IN  SANs
141619623  gpsowl.com   2017-May-21 03:03 CEST  2017-Aug-19 03:03 CEST  88 days     gpsowl.com

140104828  gpsowl.com   2017-May-18 04:12 CEST  2017-Aug-16 04:12 CEST  85 days     gpsowl.com

133064925  gpsowl.com   2017-May-05 03:13 CEST  2017-Aug-03 03:13 CEST  72 days     gpsowl.com

So you need to identify which is the right one, I think is the one containin domain and ww domain. I suppose that the right cert containing both domains is located at /etc/letsencrypt/live/gpsowl.com/ and the cert containing only your domain is located at /etc/letsencrypt/live/gpsowl.com-0001/

To identify how many domains contains your cert can use this:

echo | openssl x509 -in /etc/letsencrypt/live/gpsowl.com/cert.pem -noout -text | grep DNS:

echo | openssl x509 -in /etc/letsencrypt/live/gpsowl.com-0001/cert.pem -noout -text | grep DNS:

Once you have identified the right cert, you need to recreate the keystore with the new key and cert.

0.- Create a dir to store your keystore, I'm using /etc/tomcat8/keystore/ for this example, you should use the path that you want.

mkdir -p /etc/tomcat8/keystore/

1.- Create a pkcs12 store (change HERETHEPASSWORD with the password you want):

openssl pkcs12 -export -in /etc/letsencrypt/live/gpsowl.com/fullchain.pem -inkey /etc/letsencrypt/live/gpsowl.com/privkey.pem -out /etc/tomcat8/keystore/gpsowl.com.p12 -password pass:HERETHEPASSWORD

2.- Import pkcs12 store into a keystore (change HERETHEPASSWORD with the password used in previous command):

keytool -importkeystore -srckeystore /etc/tomcat8/keystore/gpsowl.com.p12 -srcstoretype pkcs12 -srcstorepass HERETHEPASSWORD -destkeystore /etc/tomcat8/keystore/gpsowl.com.keystore -deststoretype jks -deststorepass HERETHEPASSWORD

3.- Configure your tomcat to use the right keystore and pass:

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" URIEncoding="UTF-8"
clientAuth="false" sslProtocol="TLS" />

4.- Restart or reload your tomcat.

I hope this helps.


1 Like

nice summary mate :smiley:

1 Like

Thanks to other people for following up on this possibility. It sounds like there’s a consensus that this is the problem—I’ll try to keep this in mind when people are using Tomcat in the future!

$ ls /etc/letsencrypt/live
gpsowl.com/ gpsowl.com-0001/

$ openssl x509 -in /etc/letsencrypt/live/gpsowl.com-0001/cert.pem -text -noout
Version: 3 (0x2)
Serial Number:
Signature Algorithm: sha256WithRSAEncryption
Issuer: C=US, O=Let’s Encrypt, CN=Let’s Encrypt Authority X3
Not Before: May 18 02:12:00 2017 GMT
Not After : Aug 16 02:12:00 2017 GMT
Subject: CN=gpsowl.com
Subject Public Key Info:
Public Key Algorithm: rsaEncryption
Public-Key: (2048 bit)
Exponent: 65537 (0x10001)
X509v3 extensions:
X509v3 Key Usage: critical
Digital Signature, Key Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication, TLS Web Client Authentication
X509v3 Basic Constraints: critical
X509v3 Subject Key Identifier:
X509v3 Authority Key Identifier:

        Authority Information Access:
            OCSP - URI:http://ocsp.int-x3.letsencrypt.org/
            CA Issuers - URI:http://cert.int-x3.letsencrypt.org/

        X509v3 Subject Alternative Name:
        X509v3 Certificate Policies:
              CPS: http://cps.letsencrypt.org
              User Notice:
                Explicit Text: This Certificate may only be relied upon by Relying Parties and only in                  accordance with the Certificate Policy found at https://letsencrypt.org/repository/

Signature Algorithm: sha256WithRSAEncryption

I don’t understands at all… I just followed the installation instructions and bam, https worked. I didn’t even edit my server.xml file, which was very strange.
A) gpsowl.com
B) okay
C) huh - have not seen instructions for this, have a link?
D) yup
E) restarted lots of times

Thank you so much, that worked! I made a small mod, looks like:

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true" URIEncoding="UTF-8"
           keystorePass="xxxxxxx" keyAlias="tomcat"
           clientAuth="false" sslProtocol="TLS" />

Hi @gerryscat,

Your are welcome, I'm glad it worked but...

As I said, you are using Nio Protocol protocol="org.apache.coyote.http11.Http11NioProtocol" and using this protocol you should not use the directive SSLCertificateFile because it is only valid if you are using APR Protocol.

If you check your logs you will see a WARNING like this:

WARNING [main] org.apache.catalina.startup.SetAllPropertiesRule.begin [SetAllPropertiesRule]{Server/Service/Connector} Setting property 'SSLCertificateFile' to '/etc/letsencrypt/live/gpsowl.com/fullchain.pem' did not find a matching property.

Also, I didn't put the keyAlias directive because if you follow the instructions I provided I've defined no alias in the keystore, so I really doubt that it can work for you, indeed tomcat should not start in port 8443 because of that and if you check your logs you will see a SEVERE error, something like this:

SEVERE [main] org.apache.coyote.AbstractProtocol.init Failed to initialize end point associated with ProtocolHandler ["http-nio-8443"]
 java.io.IOException: Alias name tomcat does not identify a key entry

So, you don't need to specify this directive. If you like this directive for some reason :wink: put the right default alias... in this case is 1.



I’ll check the logs later.

It did not work until I added the SSLCertificateFile part, so that’s weird.

@gerryscat, please check the logs, I’m very curious because SSlCertificateFile is not a valid directive for Nio protocol. Are you sure this conf doesn’t work without adding SSLCertificaFile AND keyAlias directives?.

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true" URIEncoding="UTF-8"
clientAuth="false" sslProtocol="TLS" />

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