Skip to main content

Gluu Server CE Cert import

๐ŸŽฏ Purpose

This guide outlines the process to securely log into the Gluu Server virtual machine (VM), retrieve the Gluu server's TLS certificate, import it into the Java truststore, and restart services to enable trusted internal HTTPS communication.


๐Ÿ”ย Logging into the Gluu VM

    ๐Ÿ–ฅ๏ธ Open a terminal or SSH client on your admin machine. ๐Ÿ”Œ Connect to your Gluu Server via SSH:
    ssh root@your-gluu-server-ip
    ๐Ÿ’ก If Gluu is running locally (e.g., in Proxmox/XCP-ng), log in via the hypervisor console directly as root.

    ๐Ÿงฐ Prerequisites

      Root or sudo access to the Gluu VM Domain name of Gluu: gluu.mslspartners.com Java truststore password (default: changeitย or custom) Tools: openssl, keytool, awk

      ๐Ÿš€ Step-by-Step Instructions

      1๏ธโƒฃ Create the Script

      nano /root/import-gluu-cert.sh

      2๏ธโƒฃ Paste the Script Below

      #!/bin/bash
      
      DOMAIN="gluu.mslspartners.com"
      CERT_PATH="/etc/certs/gluu-full-chain.crt"
      KEYSTORE_PATH="/opt/jre/lib/security/cacerts"
      KEYSTORE_PASS="changeit"
      ALIAS="gluu-remote"
      
      echo "๐Ÿ” Fetching certificate from $DOMAIN..."
      openssl s_client -showcerts -connect ${DOMAIN}:443 </dev/null \
        | awk '/BEGIN CERT/,/END CERT/ { print }' > "$CERT_PATH"
      
      if [[ $? -ne 0 ]]; then
        echo "โŒ Failed to retrieve certificate."
        exit 1
      fi
      
      echo "๐Ÿ—‘๏ธ Removing old certificate (if any)..."
      keytool -delete -alias "$ALIAS" -keystore "$KEYSTORE_PATH" -storepass "$KEYSTORE_PASS" 2>/dev/null
      
      echo "โž• Importing new certificate..."
      keytool -import -alias "$ALIAS" \
        -keystore "$KEYSTORE_PATH" \
        -trustcacerts -file "$CERT_PATH" \
        -storepass "$KEYSTORE_PASS" -noprompt
      
      echo "๐Ÿ” Restarting Gluu services..."
      /root/restart-gluu.sh
      
      echo "โœ… Import and restart complete!"
      

      3๏ธโƒฃ Make the Script Executable

      chmod +x /root/import-gluu-cert.sh

      4๏ธโƒฃ Run the Script

      /root/import-gluu-cert.sh

      ๐Ÿ” Verifying Certificate Import

      ๐Ÿงพ Check Truststore Entry:

      keytool -list -keystore /opt/jre/lib/security/cacerts -storepass changeit | grep gluu-remote

      ๐Ÿ”’ Check Active Truststore in Java:

      /opt/jre/bin/java -XshowSettings:properties -version 2>&1 | grep trustStore

      ๐Ÿ“› Confirm Issuer/Subject:

      openssl x509 -in /etc/certs/gluu-full-chain.crt -noout -issuer -subject

      ๐Ÿ›  Troubleshooting

        โ— SSL Errors:ย Usually mean the cert isn't trusted. Double-check import step. ๐Ÿ”’ Permission Denied:ย Ensure you're running as root. ๐Ÿงฑ Service Not Restarting:ย Review logs in /opt/gluu/jetty/<app>/logs/.

        ๐Ÿ“˜ Notes

          This guide is for internal/self-signed Gluu certificates. Public CA certs usually donโ€™t require this step unless using a non-standard CA. The script assumes a restart script exists at /root/restart-gluu.sh.

          ๐Ÿ”‘ Step 1: SSH intoInto the Host ServerMachine

          UseFrom SSHyour tolocal terminal, connect to your Gluu server:server host:

          ssh root@your-gluu-server-ip

          Replace your-gluu-server-ip with theyour actual IPย address or hostname.


          ๐Ÿงญ๐Ÿ“ฆ Step 2: EnterLog In to the Gluu Chroot Environment

          ToGluu manageruns Gluu,inside youa mustchroot entercontainer. theEnter isolatedit environment:with:

          /sbin/gluu-serverd login

          OnceYouโ€™ll inside,know youyou're willinside seewhen theyour prompt change,changes (e.g.:

          ,
          [gluu@gluu ~]#
          ).

          ๐Ÿ“‚๐Ÿ“ Step 3: Navigate tothe Gluu DirectoriesFile Structure

          ComponentsCore like oxAuth, Identity, IDP, etc.,services areย found under:

          cd /opt/gluu/jetty/
            oxauth: OAuth2/OpenID Connect Provider identity: Admin UI (oxTrust) idp: SAML IDP scim: SCIM User Management fido2: FIDO2 Service casa: User Self-Service Portal

            ๐Ÿ“Š๐Ÿ“œ Step 4: CheckView Logsย for Troubleshooting

            To viewCheck the lastmost 50recent log lines offor a service'sservice. logExample file, run:(oxAuth):

            tail -n 50 /opt/gluu/jetty/oxauth/logs/oxauth.log

            Replace oxauthย with the appropriate service name as needed.


            โ™ป๏ธ๐Ÿ” Step 5: Restart Gluu Services

            If

            Option youA: haveUsing a restart script:Script

            /root/restart-gluu.sh

            Or

            Option restartB: specificManual servicesService manually:Restart

            
            cd /opt/gluu/jetty/oxauthย &&
            nohup java -jar ../../jetty/start.jar > oxauth.log 2>&1 &
            

            Repeat for other services like identity, idp, etc.


            ๐Ÿ”’๐Ÿ” Step 6: VerifyCheck Running Java Trust StoreServices

            keytool

            Use -listthis -keystoreto /etc/ssl/certs/java/cacertsverify -storepassif 'changeit'services |are grep gluu

            ๐Ÿšฆ Step 7: Check Java Processes

            active:
            ps aux | grep java | grep -v grep

            ๐Ÿ’ก๐Ÿ” Tip:Step 7: Verify Java Truststore for Certificates

            Ensure custom certs are loaded:

            keytool -list -keystore /etc/ssl/certs/java/cacerts -storepass 'your-password' | grep gluu

            ๐Ÿšช Step 8: Exit the Gluu Chroot Environment

            To return to the regular Linux shell:

            exit

            This returns you to the main server shell.


            โœ…๐Ÿ“ Summary

            • Login:๐Ÿ› ๏ธ Use /sbin/gluu-serverd loginย to manage Gluu internals
            • Services:๐Ÿงญ LocatedServices inlocated at /opt/gluu/jettyjetty/
            • Logs:๐Ÿ“ˆ Logs help debug services under /logs
            ๐Ÿ” Use tailkeytool to inspectverify Restart:Java Usetruststore script or start.jar per service Truststore: Managed with keytoolcertificates

            ๐Ÿ”ง๐Ÿ’ก ForTip: persistentAlways issues,ensure validate SSLyour certificates andare inspecttrusted oxauth.logby andthe oxtrust.log.JVM for SSL-based connections to succeed!