If you do not want to add the certificate to the JVM and store this certificate separately. You can download the certificate as part of your code, as shown below.
'// load certificate InputStream fis = this.getClass (). GetResourceAsStream ("file / path / to / your / certificate.crt"); CertificateFactory cf = CertificateFactory.getInstance ("X.509"); Certificate cert = cf.generateCertificate (fis);
// load the keystore that includes self-signed cert as a "trusted" entry KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); keyStore.load(null, null); TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); keyStore.setCertificateEntry("cert-alias", cert); tmf.init(keyStore); SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(null, tmf.getTrustManagers(), null);'
then attach a light builder of type to rest
resteasyClientBuilder.sslContext(sslContext)
source share