Was able to connect to test.mosquitto.org:8883 by adding the sites certificate to the java cacerts file and running the code below.
found here IBM Docs
KeyStore keyStore = KeyStore.getInstance("JKS");
// load default jvm keystore
keyStore.load(new FileInputStream(
System.getProperties()
.getProperty("java.home") + File.separator
+ "lib" + File.separator + "security" + File.separator
+ "cacerts"), "changeit".toCharArray());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(
TrustManagerFactory.getDefaultAlgorithm());
tmf.init(keyStore);
Mqtt5BlockingClient client2 = Mqtt5Client.builder()
.identifier(UUID.randomUUID().toString())
.serverHost("test.mosquitto.org")
.serverPort(8883)
.sslConfig()
.trustManagerFactory(tmf)
.applySslConfig()
.buildBlocking();
client2.connect();