How To install SSL Certificate on WildFly for Windows

Welcome back to by personal blog. So today i'm going to share my knowledge about SSL implementation on Wild-fly for Windows. And also I assure that you will not find any problem in this blog post. However, if there is any mistake, please post the problem in the comment section.
Assumed that I have certificate.pem and the key.pem only. Both two file has .pem extension. And I used OpenSSL commands to configure ssl certificate. You can use below link for OpenSSL. it will help you to configure OpenSSL on your windows machine. How to configure OpenSSL

Step 01 :
You need to create .p12 file by using above public certificate and  private key


openssl pkcs12 -export -in (certificate.pem) -name (your_domain_name) -inkey (private_key.pem) -passin pass:(password) -out (output_file_name.p12) -passout pass:(password)


openssl pkcs12 -export -in a235sdjg7235.pem -name xx.yy.com -inkey privatekey.pem -passin pass:asg32fj -out newcreatedcertificate.p12 -passout pass:asg32fj
 
Step 02 :
Create a folder inside your wild-fly directory. Normally we create that directory inside a below path and name that newly created folder with "sslstore". (wilflyfalder/standalone/configuration/sslstore)

Step 03 :
Then we are going to create KeyStore for our wild-fly server.

keytool -genkey -alias (your_domain_name) -keyalg RSA -keysize 2048 -keystore (key_store_name) 

keytool -genkey -alias xx.yy.come -keyalg RSA -keysize 2048 -keystore mykeystore 

Inhere they will ask about first name and the last name at that time remember to add your_domain_name as a first name and the last name section. The other questions are your company name, department and location. You can give your correct details to provide under above section.And provide some valid password and noted it on text file

Step 04 :
You should need to delete default certificate which auto generated with the keyStore. Before that, you need to check how many certificates are currently installed on the above KeyStore. So use below OpenSSL commands to check how many certificates are available on that KeyStore.

keytool -v -list -keystore (key_store_name)

keytool -v -list -keystore mykeystore


In here system will ask about the password  then you need to enter password which you provide on the Step 03. and then it will show how many certificates(entries)  available on now. Normally there is a one entry.

Step 05 :
if is there a any certificate in a KeyStore. You need to delete that one using bellow OpenSSL command.

keytool -delete -alias(your_domain_name) -keystore (key_store_name)

keytool -delete -alias xx.yy.com -keystore mykeystore

In here olso same as the Step 04, system will ask about the password  then you need to enter password which you provide on the Step 03. So do the same steps again that you did on above Step 04 and it will show zero entry is  available on your  KeyStore. Happy to say now your Keystore is fully cleared to install new certificate which we created on Step 01.
 
Step 06 : 
Now we need to import above certificate that we created on Step one.

keytool -v -importkeystore -srckeystore (correct_path_to_above_created_.p12 file location) -srcstoretype PKCS12 -destkeystore (key_store_name_path) -deststoretype JKS

keytool -v -importkeystore -srckeystore C:\Users\prihanwildlfy\standalone\configuration\sslstore\user.p12 -srcstoretype PKCS12 -destkeystore C:\Users\prihanwildlfy\standalone\configuration\sslstore\mykeystore -deststoretype JKS
 
Step 07 :
 In this step need to open your standalone.xml file and change the following lines according to your sslstore path. please be careful to add below lines inside a management tag.

<management>
        <security-realms>
            <security-realm name="SslRealm">
                <server-identities>
                    <ssl>
                        <keystore path="
C:\Users\prihanwildlfy\standalone\configuration\sslstore\mykeystore" keystore-password="
asg32fj" alias="xx.yy.com"/>
                    </ssl>
                </server-identities>
            </security-realm>

Step 08 :
Next step is add a bellow blue colred line to your standalone.xml file under subsytem tag.

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
            <buffer-cache name="default"/>
            <server name="default-server">
                <http-listener name="default" socket-binding="http" max-post-size="104857600" max-parameters="10000" redirect-socket="https"/>
                <https-listener name="default-ssl" socket-binding="https" security-realm="SslRealm"/>
               
Step 09 :
Final step is change the ssl port as bellow in socket-binding tag.

<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
        <socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
        <socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
        <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
        <socket-binding name="http" port="80"/> 

       <socket-binding name="https" port="443"/> 

Step 10 :
Now save the standalone.xml file and start your Wild-fly sever. Now you can access your website via https://xx.yyy.com.This was the final step of the ssl implementation process. 

--- End ---

Comments

Sacheen Warnaka said…
Valuable content.Thanks for sharing

Popular posts from this blog

How To install SSL Certificate on WildFly for CentOS 7

Configure Android Studio 2.3.2 for Kotlin