Saturday, April 18, 2015

HTTPS in Wildfly

Create a certificate store (file name wildfly.jks) placed in configuration directory. Add both CA root public certificate and SSL certificate (including private key, like PKCS#12 format).

Add a security-realm in security-realms section.

        <security-realms>
...
            <security-realm name="SslRealm">
                <server-identities>
                    <ssl>
                        <keystore path="wildfly.jks" relative-to="jboss.server.config.dir" keystore-password="secret4jks" alias="alias-of-ssl-certificate" key-password="secret4certificate"/>
                    </ssl>
                </server-identities>
            </security-realm>
        </security-realms>

Add a https-listener referring the previously defined security-realm

        <subsystem xmlns="urn:jboss:domain:undertow:1.2">
            <buffer-cache name="default"/>
            <server name="default-server">
                <http-listener name="default" socket-binding="http" max-parameters="5000"/>
                <https-listener name="default-ssl" socket-binding="https" security-realm="SslRealm"/>
...

PHA+Q3JlYXRlIGEgY2VydGlmaWNhdGUgc3RvcmUgKGZpbGUgbmFtZSA8c3Ryb25nPndpbGRmbHkuamtzPC9zdHJvbmc+KSBwbGFjZWQgaW4gY29uZmlndXJhdGlvbiBkaXJlY3RvcnkuIEFkZCBib3RoIENBIHJvb3QgIHB1YmxpYyBjZXJ0aWZpY2F0ZSBhbmQgU1NMIGNlcnRpZmljYXRlIChpbmNsdWRpbmcgcHJpdmF0ZSBrZXksIGxpa2UgPHN0cm9uZz5QS0NTIzEyPC9zdHJvbmc+IGZvcm1hdCkuPC9wPg0KPHA+QWRkIGEgPGNvZGU+c2VjdXJpdHktcmVhbG08L2NvZGU+IGluIDxjb2RlPnNlY3VyaXR5LXJlYWxtczwvY29kZT4gc2VjdGlvbi48L3A+DQo8cHJlPjxjb2RlIGNsYXNzPSJsYW5ndWFnZS14bWwiPiAgICAgICAgJmx0O3NlY3VyaXR5LXJlYWxtcyZndDsNCi4uLg0KICAgICAgICAgICAgJmx0O3NlY3VyaXR5LXJlYWxtIG5hbWU9JnF1b3Q7U3NsUmVhbG0mcXVvdDsmZ3Q7DQogICAgICAgICAgICAgICAgJmx0O3NlcnZlci1pZGVudGl0aWVzJmd0Ow0KICAgICAgIC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