We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Email for Java: How to support IMAP servers with self signed certificates?

We need to access IMAP servers with self signed certificates using Aspose Email for Java?

What is your suggested way?
setSocketsLayerVersion2DisableSSLCertificateValidation is deprecated in version 22.11. I could not find any documentation about the exact effect it has.
The constructor parameter RemoteCertificateValidationCallback is obfuscated. How could that one be used? Referenced here:

Hello @ugort,

You can ignore certificate validation using custom SSLSocketFactory:

import java.security.cert.CertificateException;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

public static SSLSocketFactory getSSLSocketFactory() {
    TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
        public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {

        public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException {

        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return new java.security.cert.X509Certificate[]{};

    try {
        SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
        sslContext.init(null, trustAllCerts, new java.security.SecureRandom());

        return sslContext.getSocketFactory();
    } catch (java.lang.Exception e) {
        throw new RuntimeException(e);

public final void test() {
    System.setProperty("javax.net.debug", "all");


    ImapClient imapClient = new ImapClient(host, port, username, password);

Perfect. Thank you for the quick response.