Skip to content
Snippets Groups Projects
Commit 39a35ff3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-3322 init trust manager factory

parent d722ac58
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,7 @@ import java.security.cert.CertificateFactory; ...@@ -14,6 +14,7 @@ import java.security.cert.CertificateFactory;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.event.Observes; import javax.enterprise.event.Observes;
import javax.net.ssl.TrustManagerFactory;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.microprofile.config.inject.ConfigProperty; import org.eclipse.microprofile.config.inject.ConfigProperty;
...@@ -43,6 +44,8 @@ class MongodbCertificateLoader { ...@@ -43,6 +44,8 @@ class MongodbCertificateLoader {
try { try {
var trustStore = initKeyStore(); var trustStore = initKeyStore();
trustStore.setCertificateEntry("ca", generateCertificate()); trustStore.setCertificateEntry("ca", generateCertificate());
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(trustStore);
return trustStore; return trustStore;
} catch (Exception e) { } catch (Exception e) {
throw new TechnicalException("Error building KeyStore", e); throw new TechnicalException("Error building KeyStore", e);
...@@ -52,7 +55,7 @@ class MongodbCertificateLoader { ...@@ -52,7 +55,7 @@ class MongodbCertificateLoader {
KeyStore initKeyStore() { KeyStore initKeyStore() {
try { try {
var trustStore = KeyStore.getInstance("pkcs12"); var trustStore = KeyStore.getInstance("pkcs12");
trustStore.load(null, null); trustStore.load(null);
return trustStore; return trustStore;
} catch (Exception e) { } catch (Exception e) {
throw new TechnicalException("Error init KeyStore", e); throw new TechnicalException("Error init KeyStore", e);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment