Skip to content

Commit

Permalink
- Adapt api for 10 (#40)
Browse files Browse the repository at this point in the history
- Remove manual reading ivy config
  • Loading branch information
nqhoan-axonivy authored Jan 3, 2025
1 parent 8345875 commit ec4901f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import com.axonivy.connector.mailstore.constant.Constants;
import com.axonivy.connector.mailstore.enums.StartTLS;

import ch.ivyteam.ivy.ssl.client.restricted.SslClientSettings;

public class SSLContextConfigure {
private static final SSLContextConfigure INSTANCE = new SSLContextConfigure();
private SSLContextConfigure() {}
Expand All @@ -37,16 +39,17 @@ public boolean isStartTLSEnabled(Properties properties) {
|| BooleanUtils.toBoolean(properties.getProperty(StartTLS.REQUIRED.getProperty()));
}

@SuppressWarnings("restriction")
public void addIvyTrustStoreToCurrentContext() throws NoSuchAlgorithmException, KeyStoreException,
CertificateException, IOException, KeyManagementException {
TrustManagerFactory tmFactory = initDefaultTrustManagerFactory();
// Backup default Certificates
X509TrustManager defaultX509CertTM = getFirstX509TrustManagerFromFactory(tmFactory);

TrustStoreFileReader trustStoreFileReader = new TrustStoreFileReader();
try (InputStream trustStoreStream = new FileInputStream(trustStoreFileReader.getTrustFile())) {
KeyStore ivyTrustStore = KeyStore.getInstance(KeyStore.getDefaultType());
ivyTrustStore.load(trustStoreStream, trustStoreFileReader.getTrustPassword());
var currentSSLClientSettings = SslClientSettings.instance();
try (InputStream trustStoreStream = new FileInputStream(currentSSLClientSettings.getTrustStoreFile())) {
KeyStore ivyTrustStore = KeyStore.getInstance(currentSSLClientSettings.getTrustStoreType());
ivyTrustStore.load(trustStoreStream, currentSSLClientSettings.getTrustStorePassword());
tmFactory = getDefaultAlgorithm();
tmFactory.init(ivyTrustStore);
X509TrustManager ivyTrustManager = getFirstX509TrustManagerFromFactory(tmFactory);
Expand Down

This file was deleted.

0 comments on commit ec4901f

Please sign in to comment.