You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by zied123456 <zi...@gmail.com> on 2015/11/24 16:37:26 UTC
Camel iMap - ignore SSL certificat
i'm using imap endpoint and i try to ignore SSL certificat by using:
the First class *DummySSLSocketFactory* :
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();
}
}
the second class *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 *DummyTrustManager* 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);
System.out.println(props);
System.out.println(session);
}
}
How can i associate this to the iMap EiP to ignore SSL Certificate ?
this is the route:
<route id="timerToLog">
<from uri="imaps://server:993?username=user_name&password=pass"/>
<log message="ok"/>
</route>
--
View this message in context: http://camel.465427.n5.nabble.com/Camel-iMap-ignore-SSL-certificat-tp5774348.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel iMap - ignore SSL certificat
Posted by Claus Ibsen <cl...@gmail.com>.
Ah the dummy impl classes was not in camel-mail JAR by default. Logged
a ticket about this: https://issues.apache.org/jira/browse/CAMEL-9374
On Sat, Nov 28, 2015 at 9:35 AM, Claus Ibsen <cl...@gmail.com> wrote:
> There is a dummyTrustManager option you can just set = true
>
> On Tue, Nov 24, 2015 at 4:37 PM, zied123456 <zi...@gmail.com> wrote:
>> i'm using imap endpoint and i try to ignore SSL certificat by using:
>>
>>
>> the First class *DummySSLSocketFactory* :
>>
>> 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();
>> }
>> }
>>
>> the second class *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 *DummyTrustManager* 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);
>> System.out.println(props);
>> System.out.println(session);
>> }
>>
>> }
>>
>> How can i associate this to the iMap EiP to ignore SSL Certificate ?
>>
>> this is the route:
>>
>> <route id="timerToLog">
>> <from uri="imaps://server:993?username=user_name&password=pass"/>
>> <log message="ok"/>
>> </route>
>>
>>
>>
>> --
>> View this message in context: http://camel.465427.n5.nabble.com/Camel-iMap-ignore-SSL-certificat-tp5774348.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2
Re: Camel iMap - ignore SSL certificat
Posted by Claus Ibsen <cl...@gmail.com>.
There is a dummyTrustManager option you can just set = true
On Tue, Nov 24, 2015 at 4:37 PM, zied123456 <zi...@gmail.com> wrote:
> i'm using imap endpoint and i try to ignore SSL certificat by using:
>
>
> the First class *DummySSLSocketFactory* :
>
> 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();
> }
> }
>
> the second class *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 *DummyTrustManager* 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);
> System.out.println(props);
> System.out.println(session);
> }
>
> }
>
> How can i associate this to the iMap EiP to ignore SSL Certificate ?
>
> this is the route:
>
> <route id="timerToLog">
> <from uri="imaps://server:993?username=user_name&password=pass"/>
> <log message="ok"/>
> </route>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Camel-iMap-ignore-SSL-certificat-tp5774348.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2