Skip to content

Instantly share code, notes, and snippets.

@jarryDk
Last active January 12, 2016 08:32
Show Gist options
  • Save jarryDk/cc192f0526cd8acedf7f to your computer and use it in GitHub Desktop.
Save jarryDk/cc192f0526cd8acedf7f to your computer and use it in GitHub Desktop.
#!/bin/bash
# Script version of http://rhoads-zach.github.io/2015/09/02/setting-up-ssltls-with-wildfly-10/
#####
#
# Before going on - start WildFly
#
# http : 8080
# https : 8443
# management-http : 9990
# management-https : 9993
#
#####
WILDFLY_HOME=/opt/wildfly/wildfly-ssl-tls-setup
echo "Creating key pairs and copy wfly.jks til WildFly"
/usr/java/latest/bin/keytool -genkeypair -alias myServer -storetype jks -keyalg RSA -keysize 2048 -keypass myPassword -keystore wfly.jks -storepass myPassword -dname "CN=myServer,OU=test,O=Developement,L=Copenhagen,ST=Copenhagen,C=DK" -validity 730 -v
cp wfly.jks $WILDFLY_HOME/standalone/configuration/
echo ""
echo "Creating a Realm for SSL/TLS"
touch $WILDFLY_HOME/standalone/configuration/https-users.properties
$WILDFLY_HOME/bin/jboss-cli.sh -c command='/core-service=management/security-realm=httpsRealm/:add'
$WILDFLY_HOME/bin/jboss-cli.sh -c command='/core-service=management/security-realm=httpsRealm/authentication=properties/:add(path=https-users.properties, relative-to=jboss.server.config.dir)'
$WILDFLY_HOME/bin/jboss-cli.sh -c command='/core-service=management/security-realm=httpsRealm/server-identity=ssl:add(keystore-path=wfly.jks,keystore-relative-to=jboss.server.config.dir,keystore-password=myPassword, alias=myServer)'
$WILDFLY_HOME/bin/jboss-cli.sh -c command='reload'
$WILDFLY_HOME/bin/add-user.sh -up $WILDFLY_HOME/standalone/configuration/https-users.properties -r httpsRealm
echo ""
echo "Enabling SSL for the Undertow Subsystem"
$WILDFLY_HOME/bin/jboss-cli.sh -c command='/subsystem=undertow/server=default-server/https-listener=default-https:add(socket-binding=https,security-realm=httpsRealm)'
echo ""
echo "Enabling SSL for Management Interfaces"
$WILDFLY_HOME/bin/jboss-cli.sh -c command='/core-service=management/management-interface=http-interface:write-attribute(name=secure-socket-binding,value=management-https)'
$WILDFLY_HOME/bin/jboss-cli.sh -c command='/core-service=management/management-interface=http-interface/:write-attribute(name=security-realm,value=httpsRealm)'
$WILDFLY_HOME/bin/jboss-cli.sh -c command='reload'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment