Since I found this question due to another error, I am writing here some possible causes of problems in similar situations.
Invalid certificate name
This refers to this issue. In Chrome, I got the following message:
NET::ERR_CERT_AUTHORITY_INVALID
You need to set CN = localhost for it to work.
What is your first and last name? [Unknown]: localhost
This is also indicated in the GlassFish Security Guide:
To verify the HTTPS host name, it is important to ensure that the certificate name (CN) matches the fully qualified host name of your site (fully qualified domain name). If the names do not match, clients connecting to the server will see a security warning stating that the certificate name does not match the site name.
Invalid Key Algorithm
I used the keytool -genkey without specifying the -keyalg option, and this created a certificate with SHA1withDSA .
Chrome said ERR_CONNECTION_CLOSED , and in my server log I found
javax.net.ssl.SSLHandshakeException: no cipher suites in common
I solved this by specifying keytool -genkey -keyalg RSA
Change also the Glassfish instance certificate
From the GlassFish Security Guide:
DAS uses the s1as alias for SSL / TLS authentication, and instances use the glassfish-instance alias
According to the comment, another answer is “If you change the s1as certificate, you will also need to change the certificate of the Glassfish instance instance.”
Invalid keystore file
Remember, that:
- The
keystore.jks file contains the GlassFish Server certificate, including its private key . - The
cacerts.jks file contains trusted GlassFish server certificates, including public keys for other objects.
Sometimes distraction can cause you to put the public key in the wrong file. This should be the correct sequence:
How to check
This command displays certificate information:
keytool -v -list -alias <the_alias> -keystore <filename>.jks
If you look at the original self-signed certificates provided by GlassFish, you:
- CN :
Owner: CN=localhost for s1asOwner: CN=localhost-instance for glassfish-instance
- RSA :
Signature algorithm name: SHA256withRSA - Record Type :
Entry type: PrivateKeyEntry for keystore.jksEntry type: trustedCertEntry for cacerts.jks