Elytron: A New Security Framework in WildFly/JBoss EAP
In this tutorial, we will create a self-signed certificate to understand how SSL/TLS works in Elytron. Read on to learn how to secure your JBoss EAP!
Join the DZone community and get the full member experience.
Join For FreeElytron is a new security framework that ships with WildFly version 10 and Red Hat JBoss Enterprise Application Platform (EAP) 7.1. This project is a complete replacement of PicketBox and JAAS. Elytron is a single security framework that will be usable for securing management access to the server and for securing applications deployed in WildFly. You can still use the legacy security framework, which is PicketBox, but it is a deprecated module; hence, there is no guarantee that PicketBox will be included in future releases of WildFly. In this article, we will explore the components of Elytron and how to configure them in Wildfly.
The Elytron project covers the following:
- SSL/TLS
- Secure credential storage
- Authentication
- Authorization
In this article, we are going to explore using SSL/TLS in WildFly with Elytron.
This is the basic architecture of SSL/TLS in Elytron:
The key attribute here is SSLContext
, which also has the reference to the following components:
- Key-Manager: key-manager keeps the reference to key-store to be used and loads the keys.
- Trust-Manager: This also keeps the reference to key-store and basically used for
trustCertificates
. If all the certificates are present in the keystore referenced by the key-manager, configuring the trust-manager is not required. However, for outbound connections, a trust-manager can be used. - Security-Domain: This is an optional parameter, however, if
SSLContext
is configured with a reference to a security-domain, then the verification of a client’s certificate can be performed as an authentication, thus ensuring the appropriate permissions for a login are assigned before even allowing the connection to be fully opened.
SSLContext
also defines the type of SSL communication (one-way/two-way) along with allowed protocols and cipher-suite details.
Configure the SSLContext to be used by the Management Interface and the Undertow Subsystem
Before we start configuring SSL/TLS in Elytron, we should have a certificate. In this tutorial, we will create a self-signed certificate to understand how SSL/TLS works in Elytron.
To manage the certificate/keystore, I have used here keytool
CLI-based utility that ships with Java. However, one can manage the certificate/keystore using another utility, such as Portecle, which allows you to manage the keystore/certificate graphically and does not require you to remember long command lines.
First, use keytool
to generate the keystore and a self-signed certificate, executing a command similar to the following in the OS terminal command line:
keytool -genkeypair -alias wildfly -keyalg RSA -sigalg SHA256withRSA -validity 365 -keysize 2048 -keypass jboss@123 -storepass jboss@123 -dname "CN=developer.jboss.org, C=IN" -ext san=dns:developers.redhat.org,dns:developers.wildfly.org -keystore wildfly.jks
Note: This is just an example, you need to change the common name (CN) and other attributes as per your organization's requirements and set the password accordingly.
Once we are ready with the certificate/keystore, need to perform the following steps to configure the Elytron subsystem for enabling SSL/TLS. Here, I am demonstrating the configuration using the JBoss CLI.
- First, we need to connect to the JBoss CLI by executing the jboss-cli command available in the directory
$WildFly_Home/bin
. - Next, configure a
key-store
component in the Elytron subsystem with the newly created keystore (here,wildfly.jks
is placed at$WildFly_Home/ssl
).
/subsystem=elytron/key-store=wildflyKS:add(type=JKS,path="${jboss.home.dir}/ssl/wildfly.jks",credential-reference={clear-text=jboss@123})
- Then, create a new
key-manager
component in the Elytron subsystem referencing thekey-store
component created above. To do this, you need to execute the command like below:
/subsystem=elytron/key-manager=wildflyKM:add(algorithm=SunX509,key-store=wildflyKS,credential-reference={clear-text=jboss@123})
Note: We are required to give the password (e.g. jboss@123) of the keystore here while creating the key-manager.
- Finally, configure a new
server-ssl-context
referencing thekey-manager
component created in the previous step:
/subsystem=elytron/server-ssl-context=wildlfySSC:add(key-manager=wildflyKM,protocols=[TLSv1.2])
To enable SSL/TLS through Elytron, we are required to execute the following two commands to configure the Undertow https-listener
and map the ssl-context
with Elytron. By default, the https-listener
is configured with the ApplicationRealm security realm, and, by default, ApplicationRealm generates a self-signed certificate during the first startup of WildFly. You need to perform batch execution because both of the commands have to execute simultaneously, otherwise you can remove the https-listener and add the https-listener again with ssl-context.
batch
/subsystem=undertow/server=default-server/https-listener=https:undefine-attribute(name=security-realm)
/subsystem=undertow/server=default-server/https-listener=https:write-attribute(name=ssl-context,value=wildlfySSC)
run-batch
Now, for the management interface to use the same ssl-context
, we need to execute the following commands in the JBoss CLI, which will also enable SSL for the management interface:
- Before, configuring
ssl-context
for the management-interface, we need to configuresecure-port
for the management-http interface for communicating over SSL/TLS.
/core-service=management/management-interface=http-interface:write-attribute(name=secure-socket-binding,value=management-https)
- Map the same
ssl-context
with management-http interface for enabling SSL/TLS.
/core-service=management/management-interface=http-interface:write-attribute(name=ssl-context,value=wildflySSC)
Now, to test your configuration and the SSL/TLS handshake, make a request over the HTTPS protocol using your browser. To do this, you can also use the openssl
command-line utility, for example:
openssl s_client -connect developers.redhat.com:8443
You can also use the SSL testing tool to check the certificate and the allowed protocol and ciphers. Once you have completed the setup, you can make your system live for use in production.
There are a couple of features in Elytron that were not there in earlier JBoss versions:
- Elytron prints a warning message in the log upon the expiration of the certificate used in the Elytron subsystem.
- It is possible to load the certificate keystore without restarting/reloading the instance, although there are still some challenges.
- Elytron also provides the facility to check the certificate details.
Published at DZone with permission of Siddhartha De, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments