Setup SSL - HTTPS On JBoss Wildfly Application Server - by Hasnat Saeed - Medium
Setup SSL - HTTPS On JBoss Wildfly Application Server - by Hasnat Saeed - Medium
Hasnat Saeed
In this tutorial, we will configure SSL/HTTPS on the JBoss Wildfly application server.
For the purposes of this tutorial, we will be working with a preinstalled Wildfly
16.0.0.Final (Java EE Full & Web Distribution).
To learn how to download and setup Wildfly, check out my article on this.
A Certificate Authority (CA) like DigiCert issues you a digitally signed certificate
against your Certificate Signing Request (CSR). The CA scrutinizes the details
provided in the CSR and once it deems everything is fine, it signs your SSL certificate
with the private key from its root and sends it back along with maybe one or more
Intermediate CA Certificates.
1 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
For a client like your browser, when it receives a Certificate Chain (end-user SSL
certificate along with any intermediate CA certificates) from the server as part of SSL
handshake, the SSL certificate validation is done by starting from the bottom of the
Certificate Chain (end-user SSL certificate) and going all the way up to the root
intermediate CA certificate. If the issuer of the root intermediate CA certificate is one of
the trusted CA roots in the client’s trust store, the client derives that the Certificate
Chain offered to it by the server is trustful.
If however along the validation path, the issuer of the topmost root intermediate
certificate is not present in the client’s trust store then the Certificate Chain is
considered broken and rejected and the SSL communication is aborted by the client with
an error or warning indicating to the user that the communication is not secured with
SSL/HTTPS because the certificate chain is not valid.
Now consider the SSL certificate that I received from a DigiCert subsidiary against my
CSR. Let us call this Digicert subsidiary ABC. Along with the end-user SSL certificate, I
also got back an intermediate CA certificate from DigiCert. I set up the certificate on my
server and then used this very nice online SSL utility to visualize the Certificate Chain
that my end-user SSL certificate carries.
2 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
As we can see, my end-user SSL certificate was digitally signed using an intermediate CA
certificate that was signed and issued by DigiCert SHA2 Secure Server CA to my
DigiCert subsidiary ABC. The DigiCert SHA2 Secure Server CA is an Intermediary Root
CA of DigiCert.
The intermediate certificate used by DigiCert SHA2 Secure Server CA, for signing the
intermediate certificate issued to ABC, was signed and issued by DigiCert Global Root
CA which is the Root CA of DigiCert.
So that was a brief overview of how SSL certificates work. Let us continue with the
tutorial.
3 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
Setup SSL/HTTPS
Get started Open in appon JBoss Wildfly
The digitally signed certificate(s) returned by the CA can be in any accepted format but
the PEM format is the most common format that CA issue certificates in. The PEM
certificates usually have extensions such as .pem, .crt, .cer, and .key. They are Base64
encoded ASCII files and contain “ -----BEGIN CERTIFICATE -----” and “-----END
CERTIFICATE -----” statements. SSL certificates, root anf intermediate CA certificates,
and private keys can all be put into the PEM format.
The CA issued certificates we will be using for this tutorial are in PEM format with .crt
extension.
Now to setup SSL on Wildfly, we first need to create a Keystore file. A Keystore file is
used to store cryptographic keys and certificates. There are three kinds of entries that
can be stored in a Keystore file depending upon the type of Keystore file it is.
Private Key: This is a type of key that is used in asymmetric cryptography. It is usually
protected with a password because of its sensitivity. It can also be used to sign a digital
signature.
Certificate: A certificate contains a public key that can identify the subject claimed in
the certificate. It is usually used to verify the identity of a server.
Now since Wildfly is written in Java, we will select a Keystore file type that is compatible
with Java.
A few different types of Keystore files for Java are JKS, JCEKS, PKCS#12, PKCS#11,
and DKS. For this tutorial, we will go with the PKCS#12 Keystore file.
The PKCS#12 is a standard portable Keystore file type that can be used with Java and
other languages. The PKCS#12 or PFX format is a binary format for storing the server
certificate, any Root or Intermediate CA certificates, and the private key in one
encryptable file. These Keystore files usually have extensions such as .pfx and .p12.
Let us create a PKCS#12 Keystore file that will hold our server’s private key (generated
4 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
when we created the Certificate Signing Request ), the end-user SSL certificate, and the
Get started Open in app
intermediate CA certificate.
Copy the private key and the certificate files to the Wildfly configuration directory
(${WILDFLY_HOME}/standalone/configuration) and run the below command while
in the same directory.
When we run the above command. we will be prompted to enter a password to secure
our PKCS#12 Keystore file. Enter the desired password and continue. A “.pfx” file by the
name wildfly-pkcs12.pfx will be created in the current directory.
We have created the PKCS#12 Keystore file using the OpenSSL library.
It includes utility functions for generating RSA private keys, Certificate Signing Requests
(CSRs), checksums, managing certificates and performing encryption/decryption. It
is also used to convert certificates in one format into another and also to create various
types of Keystore files.
Before we continue further, let us discuss the different attributes of the OpenSSL
command that we used above to generate a PKCS#12 Keystore file.
-export -out wildfly-pkcs12.pfx : Export and save the PKCS#12 file as wildfly-
-in mydomain.crt : The end-user SSL certificate returned by the certificate signing
authority.
-inKey server-prv.key : The private key of the server that was generated when the
5 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
we would like to include in the PKCS#12 Keystore file. In our case, we do have an
intermediate CA certificate that was returned by the certificate signing authority
along with our end-user SSL certificate.
Once the Keystore file is created, we now need to configure the Wildfly server for
SSL/HTTPS.
While in the Wildfly configuration directory, open the standalone.xml file and make the
following changes.
<security-realm name="UndertowRealm">
<server-identities>
<ssl>
<keystore path="wildfly-pkcs12.pfx" relative-
to="jboss.server.config.dir" keystore-password="<your-password>" />
</ssl>
</server-identities>
</security-realm>
The attribute relative-to is where we specify the parent directory path to which the
value of path attribute is relative to. Its value is jboss.server.config.dir which is a
property placeholder for the Wildfly configuration directory and translates to
${WILDFLY_HOME}/wildfly/standalone/configuration/.
Now locate the configuration for the undertow subsystem in your standalone.xml and
make changes to the <https-listener> element as shown below.
6 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
enabled:${wildfly.statistics-enabled:false}}">
Get started Open in app
<buffer-cache name="default"/>
<server name="default-server">
<http-listener name="default" socket-binding="http" redirect-
socket="https" enable-http2="true"/>
<https-listener name="https" socket-binding="https" security-
realm="UndertowRealm" enable-http2="true"/>
<host name="default-host" alias="localhost">
<location name="/" handler="welcome-content"/>
<http-invoker security-realm="ApplicationRealm"/>
</host>
</server>
<servlet-container name="default">
<jsp-config/>
<websockets/>
</servlet-container>
<handlers>
<file name="welcome-content" path="${jboss.home.dir}/welcome-
content"/>
</handlers>
</subsystem>
Wildfly by default listens for HTTPS traffic on TCP port 8443. However, the standard
TCP port used by HTTPS connections is 443. We can use the iptables utility to configure
the Linux kernel firewall and redirect HTTPS traffic on port 443 to port 8443 that is
used by Wildfly for HTTPS communication.
7 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
If you now click the “lock” icon (again for IE users), a window pops up and you can see
the details of the SSL certificate. As you can see below, the SSL certificate for my domain
was issued by the DigiCert SHA2 Secure Server CA which is an Intermediary Root CA
Also, if you click the “Certification Path” tab, you can actually see the entire
certification chain laid out visually as we discussed above.
8 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
This concludes our tutorial on setting up SSL/HTTPS on the JBoss Wildfly server.
Thanks for reading!! If you enjoyed this article, please clap and leave a comment. Also,
check out my other articles as well.
Here are some useful resources that inspired me to create the content of this article:
9 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
OpenSSL
OpenSSL is a robust, commercial-grade, and full-featured toolkit for the Transport Layer
Security (TLS) and Secure…
www.openssl.org
10 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
11 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
12 of 13 3/4/21, 16:01
Setup SSL/HTTPS on JBoss Wildfly Application Server | ... https://medium.com/@hasnat.saeed/setup-ssl-https-on-jb...
13 of 13 3/4/21, 16:01