I had a similar issue where I needed to test whether the correct cert was added to the Java keystore. This blog post by Matthew Davis shows a simple method for doing so. It does require access to a JDK.
Source: https://matthewdavis111.com/java/poke-ssl-test-java-certs/
Install JDK (if needed)
# Debian/Ubuntu
apt-get install -y default-jdk
# Rockylinux/Alma
dnf install -y java-latest-openjdk-devel
Source Code
Save the following to SSLPoke.java
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
if (args.length != 2) {
System.out.println("Usage: "+SSLPoke.class.getName()+" <host> <port>");
System.exit(1);
}
try {
SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket(args[0], Integer.parseInt(args[1]));
InputStream in = sslsocket.getInputStream();
OutputStream out = sslsocket.getOutputStream();
// Write a test byte to get a reaction :)
out.write(1);
while (in.available() > 0) {
System.out.print(in.read());
}
System.out.println("Successfully connected");
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
Compile the app
Run the following which will produce a Java class file SSLPoke.class
javac SSLPoke.java
Run the app
java SSLPoke <hostname> <port>
# e.g. java SSLPoke google.com 443
A message saying Successfully connected means the https connection is trusted, otherwise an exception will be printed.