This topic describes how to install and configure an SSL certificate on a GlassFish server. It covers downloading and uploading certificate files, configuring the certificate, certificate chain, and private key, and verifying the installation.
This topic uses the default domain1 container in GlassFish 4.1.2-web on Linux as an example. The steps may differ depending on your operating system or GlassFish version.
Before you begin
You have purchased and applied for a certificate by using the SSL Certificates Service, and its Status is Issued. To purchase and apply for a certificate, see Purchase a paid certificate and Apply for a certificate.
Your domain name is correctly resolved to the current server.
You have administrative permissions on this server (a root account or an account with sudo permissions).
Procedure
Step 1: Download the SSL certificate
On the SSL Certificates page, find the certificate you want to deploy and confirm the following information:
Certificate Status: Make sure that the status is Issued. If the status is About to Expire or Expired, you must renew the SSL certificate.
Bound Domains: Make sure that the certificate covers all domain names that you want to protect. Otherwise, browsers show security warnings when users access unmatched domain names over HTTPS. To add or modify domain names, see Add and replace domain names.
In the Actions column of the target certificate, click More to go to the certificate details page. On the Download tab, download the certificate whose Server Type is Other.
Decompress the downloaded certificate package.
If the package contains both a certificate file (.pem) and a private key file (.key), securely store both files. You need them for deployment.
If the package contains only a certificate file (.pem) and no private key file (.key), you must deploy the certificate together with the private key file that you saved locally.
NoteIf you generated a certificate signing request (CSR) file by using a tool such as OpenSSL or Keytool when you applied for the certificate, the private key file is stored only on your local machine and the downloaded package does not contain the private key file. If the private key is lost, the certificate becomes unusable. You must purchase a paid certificate and generate a new CSR and private key.
Step 2: Install the certificate on GlassFish
Log on to your Linux server.
Alibaba Cloud server
The following operations use an Alibaba Cloud ECS instance as an example. For other types of servers, see their respective documentation.
Log on to the ECS console. In the top navigation bar, select the region where the target ECS instance is located.
In the left-side navigation pane, choose . On the Instances page, find the target ECS instance and click Remote Connection in the Remote connection column.
In the dialog box that appears, select Workbench and click Sign in now.
Select Terminal Connection as the connection method, enter the authentication information, and follow the on-screen instructions to complete the logon. You can then access the server terminal. For more information, see Connect to an ECS instance by using Workbench.
NoteIf the Security Group Whitelist Opening Prompt panel appears, click Add Rule as prompted.
Other cloud providers
Use the remote connection feature provided by the cloud provider to log on to the server terminal.
On-premises servers
Use an SSH tool on your local machine to log on to the server terminal.
Windows: Run the
ssh <username>@<server_ip_address>command in Command Prompt (cmd) or PowerShell. If the ssh command is not supported, you can use a third-party tool, such as PuTTY or WinSCP, to establish a connection.macOS/Linux: Run the
ssh <username>@<server_ip_address>command in the built-in terminal.
Some of the following commands vary based on the operating system. Select the appropriate command for your server's OS.
RHEL/CentOS series: includes Alibaba Cloud Linux, Red Hat Enterprise Linux, CentOS, AlmaLinux, Rocky Linux, Anolis OS, and their derivatives.
Debian/Ubuntu series: includes Debian, Ubuntu, and their derivatives.
Open port 443 in the security group and firewall.
Run the following command in the server terminal to check whether port 443 is open:
RHEL/CentOS
command -v nc > /dev/null 2>&1 || sudo yum install -y nc # Replace <your_server_public_ip_address> with the public IP address of your server. sudo ss -tlnp | grep -q ':443 ' || sudo nc -l 443 & sleep 1; nc -w 3 -vz <your_server_public_ip_address> 443If the output contains
Ncat: Connected to <your_server_public_ip_address>:443, port 443 is open. Otherwise, you must open port 443 in the security group and firewall.Debian/Ubuntu
command -v nc > /dev/null 2>&1 || sudo apt-get install -y netcat # Replace <your_server_public_ip_address> with the public IP address of your server. sudo ss -tlnp | grep -q ':443 ' || sudo nc -l -p 443 & sleep 1; nc -w 3 -vz <your_server_public_ip_address> 443If the output contains
Connection to <your_server_public_ip_address> port [tcp/https] succeeded!or[<your_server_public_ip_address>] 443 (https) open, port 443 is open. Otherwise, you must open port 443 in the security group and firewall.Open port 443 in the security group.
ImportantIf your server is deployed on a cloud platform, make sure that its security group allows inbound traffic on TCP port 443. Otherwise, the service is not accessible from the internet. The following operations use an Alibaba Cloud ECS instance as an example. For other cloud platforms, see their official documentation.
Go to the ECS Instances page and click the name of the target instance to go to its details page. For more information, see Add a security group rule. Add a rule to the security group with Action set to Allow, Protocol Type set to TCP, Port Range set to HTTPS(443), and Authorization Object set to Anywhere (0.0.0.0/0).
Open port 443 in the firewall.
Run the following command to identify the current firewall service on your system:
if command -v systemctl >/dev/null 2>&1 && systemctl is-active --quiet firewalld; then echo "firewalld" elif command -v ufw >/dev/null 2>&1 && sudo ufw status | grep -qw active; then echo "ufw" elif command -v nft >/dev/null 2>&1 && sudo nft list ruleset 2>/dev/null | grep -q 'table'; then echo "nftables" elif command -v systemctl >/dev/null 2>&1 && systemctl is-active --quiet iptables; then echo "iptables" elif command -v iptables >/dev/null 2>&1 && sudo iptables -L 2>/dev/null | grep -qE 'REJECT|DROP|ACCEPT'; then echo "iptables" else echo "none" fiIf the output is
none, no further action is required. Otherwise, based on the firewall type (firewalld,ufw,nftables, oriptables), run the corresponding command to open port 443:firewalld
sudo firewall-cmd --permanent --add-port=443/tcp && sudo firewall-cmd --reloadufw
sudo ufw allow 443/tcpnftables
sudo nft add table inet filter 2>/dev/null sudo nft add chain inet filter input '{ type filter hook input priority 0; }' 2>/dev/null sudo nft add rule inet filter input tcp dport 443 counter accept 2>/dev/nulliptables
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPTTo prevent iptables rules from being lost after a system reboot, run the following command to make the rules persistent:
RHEL/CentOS
sudo yum install -y iptables-services sudo service iptables saveDebian/Ubuntu
sudo apt-get install -y iptables-persistent sudo iptables-save | sudo tee /etc/iptables/rules.v4 >/dev/null
Create a directory to store the certificate.
Go to the GlassFish installation directory (this example uses
/home/glassfish4), create a directory namedcert, and then navigate into it.cd /home/glassfish4 mkdir cert cd certUpload the certificate and private key files to the
certdirectory.NoteYou can use the local file upload feature of a remote logon tool to upload files. Examples of such tools include PuTTY, Xshell, or WinSCP. If you use an Alibaba Cloud Elastic Compute Service instance, see Upload or download files for more information.
Convert the certificate from PEM to PKCS12 format.
GlassFish uses the JKS keystore format, so you must first convert the PEM certificate to PKCS12 format. In the
certdirectory, run the following command to generate a file namedmycert.p12with the alias set tos1as.openssl pkcs12 -export -in domain_name.pem -inkey domain_name.key -out mycert.p12 -name s1asNoteReplace
domain_name.pemanddomain_name.keywith the actual paths to your certificate and private key files.When prompted, set the export password. We recommend using the default GlassFish keystore (keystore.jks) password, which is
changeit, to avoid configuration issues later. If you use a different password, you must synchronize the key entry password in a later step.
Stop the GlassFish service.
Stop the service before you modify the keystore and configuration:
/home/glassfish4/glassfish/bin/asadmin stop-domain domain1Back up the keystore and configuration files.
To prevent startup failures caused by configuration errors, back up the default GlassFish keystore file
keystore.jksand the domain configuration file.cp /home/glassfish4/glassfish/domains/domain1/config/keystore.jks /home/glassfish4/glassfish/domains/domain1/config/keystore.jks.bak cp /home/glassfish4/glassfish/domains/domain1/config/domain.xml /home/glassfish4/glassfish/domains/domain1/config/domain.xml.bakRemove the default certificate alias.
By default, GlassFish uses the
s1asalias for SSL communication. Delete this default entry from the keystore so you can replace it with your certificate.keytool -delete -alias s1as -keystore /home/glassfish4/glassfish/domains/domain1/config/keystore.jksWhen prompted, enter the keystore.jks password. The default password is
changeit.Import the new certificate into the keystore.
Import
mycert.p12into thekeystore.jkskeystore with the alias set tos1as.keytool -importkeystore \ -srckeystore mycert.p12 -srcstoretype PKCS12 \ -destkeystore /home/glassfish4/glassfish/domains/domain1/config/keystore.jks \ -deststoretype JKS \ -alias s1asWhen prompted, enter the following passwords:
Destination keystore password: Enter the
keystore.jkspassword (default:changeit).Source keystore password: Enter the export password you set for
mycert.p12in Step 5.If the export password for
mycert.p12differs from thekeystore.jkspassword, run the following command to synchronize the key entry password:keytool -keypasswd -alias s1as \ -keystore /home/glassfish4/glassfish/domains/domain1/config/keystore.jks \ -storepass <keystore.jks_password> \ -keypass <mycert.p12_export_password> \ -new <keystore.jks_password>
Update the port configuration.
Edit
/home/glassfish4/glassfish/domains/domain1/config/domain.xml. Find the<network-listeners>section and change the HTTP and HTTPS ports to 80 and 443 as shown below:<network-listeners> <network-listener protocol="http-listener-1" port="80" name="http-listener-1" thread-pool="http-thread-pool" transport="tcp"></network-listener> <network-listener protocol="http-listener-2" port="443" name="http-listener-2" thread-pool="http-thread-pool" transport="tcp"></network-listener> <network-listener protocol="admin-listener" port="4848" name="admin-listener" thread-pool="admin-thread-pool" transport="tcp"></network-listener> </network-listeners>Start the GlassFish service.
cd /home/glassfish4/glassfish/bin sudo ./asadmin start-domain domain1
Step 3: Verify the installation
Access your domain name over HTTPS. Example:
https://example.com. Replaceexample.comwith your actual domain name.If a lock icon appears in the browser's address bar, the certificate is deployed successfully. If an access error occurs or the lock icon does not appear, clear your browser's cache or try again in incognito or private mode.

Starting with Chrome 117, the
icon in the address bar has been replaced by a new
icon. Click this icon to view the security lock information.
If the issue persists, see the FAQ section for troubleshooting.
FAQ
Certificate not working or HTTPS inaccessible
Common causes include:
Port 443 is not open in the security group or firewall. See Open port 443 in the security group and firewall.
The certificate's Bound Domains does not include the domain you are accessing. See Verify that the certificate matches the target domains.
The GlassFish service was not restarted after you modified the configuration. To restart the service, see Start the GlassFish service.
The certificate files were not replaced correctly, or the certificate path in the GlassFish configuration is incorrect. Verify that your certificate configuration and files are current and valid.
The domain name is integrated with cloud services such as CDN, SLB, or WAF, but the certificate is not installed on the corresponding service. For more information, see Certificate deployment location when traffic passes through multiple cloud services.
The domain name resolves to multiple servers, but the certificate is installed on only some of them. You must install the certificate on each server.
For further troubleshooting, see Troubleshoot certificate deployment issues based on browser errors and SSL certificate deployment troubleshooting guide.
Update an installed SSL certificate
Back up the original certificate files (.pem and .key) on your server. Then, log on to the Certificate Management Service console, download the new certificate files, and upload them to the server to overwrite the originals. Make sure the file paths and names remain the same. Finally, restart the GlassFish service for the new certificate to take effect.