Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
驼峰iMap-忽略SSL证书_Ssl_Apache Camel_Jakarta Mail_Imap_Blueprint Osgi - Fatal编程技术网

驼峰iMap-忽略SSL证书

驼峰iMap-忽略SSL证书,ssl,apache-camel,jakarta-mail,imap,blueprint-osgi,Ssl,Apache Camel,Jakarta Mail,Imap,Blueprint Osgi,我使用的是imap端点,我尝试通过以下方式忽略SSL证书: 一级DummyslssocketFactory: public class DummySSLSocketFactory extends SSLSocketFactory { private SSLSocketFactory factory; public DummySSLSocketFactory() { try { SSLContext s

我使用的是imap端点,我尝试通过以下方式忽略SSL证书:

一级DummyslssocketFactory:

    public class DummySSLSocketFactory extends SSLSocketFactory {
        private SSLSocketFactory factory;
        public DummySSLSocketFactory() {
            try {
                SSLContext sslcontext = SSLContext.getInstance("TLS");
                sslcontext.init(null,
                                     new TrustManager[] { new

DummyTrustManager()},
                                 null);
            factory = (SSLSocketFactory)sslcontext.getSocketFactory();
        } catch(Exception ex) {
            // ignore
        }
    }

    public static SocketFactory getDefault() {
        return new DummySSLSocketFactory();
    }

    public Socket createSocket() throws IOException {
        return factory.createSocket();
    }

    public Socket createSocket(Socket socket, String s, int i, boolean flag)
                                throws IOException {
        return factory.createSocket(socket, s, i, flag);
    }

    public Socket createSocket(InetAddress inaddr, int i,
                                InetAddress inaddr1, int j) throws IOException {
        return factory.createSocket(inaddr, i, inaddr1, j);
    }

    public Socket createSocket(InetAddress inaddr, int i)
                                throws IOException {
        return factory.createSocket(inaddr, i);
    }

    public Socket createSocket(String s, int i, InetAddress inaddr, int j)
                                throws IOException {
        return factory.createSocket(s, i, inaddr, j);
    }

    public Socket createSocket(String s, int i) throws IOException {
        return factory.createSocket(s, i);
    }

    public String[] getDefaultCipherSuites() {
        return factory.getDefaultCipherSuites();
    }

    public String[] getSupportedCipherSuites() {
        return factory.getSupportedCipherSuites();
    }
}
第二类DummyTrustManager:

public class DummyTrustManager implements X509TrustManager {

    public void checkClientTrusted(X509Certificate[] cert, String authType) {
        // everything is trusted
    }

    public void checkServerTrusted(X509Certificate[] cert, String authType) {
        // everything is trusted
    }

    public X509Certificate[] getAcceptedIssuers() {
        return new X509Certificate[0];
    }
}

the third class AllowAll to set java mail propeties:

public class AllowAll {
         public void setsslproperties()  {

                 //DummySSLSocketFactory easy = new EasySSLProtocolSocketFactory();
                 Properties props = System.getProperties();
                 props.setProperty("mail.imap.ssl.enable", "true");
             props.setProperty("mail.imap.ssl.socketFactory.class","com.mycompany.imapssl.DummySSLSocketFactory");
                 props.setProperty("mail.imap.ssl.socketFactory.fallback", "false");
                 props.setProperty("mail.imap.socketFactory.port", "993");
                 Session session = Session.getInstance(props, null);

        }

}
如何将其与iMap EiP关联以忽略SSL证书

这是路线:

<route id="timerToLog">
    <from uri="imaps://server:993?username=user_name&password=pass"/>
    <log message="ok"/>


如果您使用的是最新版本的JavaMail,请将属性设置为要信任的主机名。这样就无需创建自己的套接字工厂