You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by James Gough <ji...@certifydatasystems.com> on 2013/01/03 01:11:27 UTC

Issue with use of SSLFilter with a custom codec

I am trying to use SSLFilter with a custom codec, but it appears that my 
client (for which I have called SSLFilter's "setUseClientMode" method 
with a setting of true), is calling SSLFilter prior to calling the 
codec, and it calls the decoder's decode method rather than the 
encoder's encode method, which is called when sslFilter is not used.

It goes something like this:

SSLFilter used:
caller -> SSLFilter -> codec's decoder.decode() method -> service

SSLFilter not used:
caller -> codec's encoder.encode() method -> service

The codec also is handed an encrypted message, which is useless since I 
have to do some stuff to it prior to sending it.

Any hints?

Re: Issue with use of SSLFilter with a custom codec

Posted by James Gough <ji...@certifydatasystems.com>.
Thanks, Claus.  I'll try to get something later this week.

On 1/6/13 2:22 AM, Claus Ibsen wrote:
> Hi James
>
> Thanks for sharing your solution.
>
> Do you mind help us with updating the camel-mina docs with your
> use-case and solution?
> http://camel.apache.org/mina
>
> If so feel free to log a JIRA ticket and attach a .txt file with a
> little description of the use-case and the Camel route snippet.
> Then we can get that added to the docs.
>
> If you want to go the full way and edit the docs yourself then see here
> http://camel.apache.org/how-do-i-edit-the-website.html
>
> On Fri, Jan 4, 2013 at 10:55 PM, James Gough <ji...@certifydatasystems.com> wrote:
>> Solution found (or stumbled upon):
>>
>> I added the following filter to my resources.groovy file:
>>
>> myCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter, mycodec)
>>
>> And I changed the URL so that:
>>
>> 1. I removed the codec entry
>> 2. I added "&allowDefaultCodec=false" to disable the adding of the default
>> codec
>> 3. I added the "myCodecFilter" entry to the filters list
>>
>> These changes resulted in the following URL:
>>
>> mina:tcp://{hostname}:{port}?sync=false&minaLogger=true&allowDefaultCodec=false&filters=#sslClientFilter,#myCodecFilter
>>
>> It all seems to be working correctly now.
>>
>> Cheers,
>>
>> Jim
>>
>>
>> On 1/4/13 10:15 AM, James Gough wrote:
>>> More data points:
>>>
>>> -It doesn't matter whether I set the client field to true, it behaves the
>>> same way no matter what the field is set to
>>>
>>> -When I called the "sendMessage" method with the grails routing plugin, it
>>> was fine with me passing it a string until I added the SSLFilter, then it
>>> threw a ClassCast exception unless I would pass it a Mina ByteBuffer
>>>
>>> Jim
>>>
>>> On 1/3/13 9:43 AM, James Gough wrote:
>>>> I'm using Camel 2.9.0 with the Mina 1.x component with the
>>>> mina-filter-ssl component imported.  I am using the Grails routing plugin's
>>>> sendMessage method to the following URL:
>>>>
>>>>
>>>> "mina:tcp://${hostname}:${port}?sync=false&minaLogger=true&codec=#mycodec&filters=#sslClientFilter"
>>>>
>>>> The SSLFilter is set up using Spring DSL, the only settings I set for the
>>>> filter is to pass a valid SSLContext to it's constructor and setting the
>>>> clientMode to true:
>>>>
>>>>    "sslContextGenerator(com.mypackage.mina.SSLContextGenerator) {
>>>>      keyStorePassword = '${keyStorePassword}'
>>>>      trustStorePassword = '${trustStorePassword}'
>>>>      keyStorePath = '${keyStorePath}'
>>>>      trustStorePath = '${trustStorePath}'
>>>>    }
>>>>
>>>>    sslContext(sslContextGenerator: "getSSLContext")
>>>>
>>>>    sslClientFilter(org.apache.mina.filter.SSLFilter, sslContext) {
>>>>      useClientMode = true
>>>>    }"
>>>>
>>>> I have verified that the SSLFilter instance does have the "client"
>>>> parameter set to true.
>>>>
>>>> I'm stumped.  It just seems like when the SSLFilter is engaged it's
>>>> behavior is entirely different.
>>>>
>>>> Jim
>>>>
>>>>
>>>> On 1/3/13 12:01 AM, Claus Ibsen wrote:
>>>>> Hi
>>>>>
>>>>> What Camel version are you using?
>>>>> And which Camel component are you referring to? Could it be camel-mina
>>>>> ? eg the Mina 1.x based component?
>>>>> And how have you configured the Camel component/route?
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Jan 3, 2013 at 1:11 AM, James Gough <ji...@certifydatasystems.com>
>>>>> wrote:
>>>>>> I am trying to use SSLFilter with a custom codec, but it appears that
>>>>>> my
>>>>>> client (for which I have called SSLFilter's "setUseClientMode" method
>>>>>> with a
>>>>>> setting of true), is calling SSLFilter prior to calling the codec, and
>>>>>> it
>>>>>> calls the decoder's decode method rather than the encoder's encode
>>>>>> method,
>>>>>> which is called when sslFilter is not used.
>>>>>>
>>>>>> It goes something like this:
>>>>>>
>>>>>> SSLFilter used:
>>>>>> caller -> SSLFilter -> codec's decoder.decode() method -> service
>>>>>>
>>>>>> SSLFilter not used:
>>>>>> caller -> codec's encoder.encode() method -> service
>>>>>>
>>>>>> The codec also is handed an encrypted message, which is useless since I
>>>>>> have
>>>>>> to do some stuff to it prior to sending it.
>>>>>>
>>>>>> Any hints?
>>>>>
>>>>>
>>>>
>>>
>
>


Re: Issue with use of SSLFilter with a custom codec

Posted by Claus Ibsen <cl...@gmail.com>.
Hi James

Thanks for sharing your solution.

Do you mind help us with updating the camel-mina docs with your
use-case and solution?
http://camel.apache.org/mina

If so feel free to log a JIRA ticket and attach a .txt file with a
little description of the use-case and the Camel route snippet.
Then we can get that added to the docs.

If you want to go the full way and edit the docs yourself then see here
http://camel.apache.org/how-do-i-edit-the-website.html

On Fri, Jan 4, 2013 at 10:55 PM, James Gough <ji...@certifydatasystems.com> wrote:
> Solution found (or stumbled upon):
>
> I added the following filter to my resources.groovy file:
>
> myCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter, mycodec)
>
> And I changed the URL so that:
>
> 1. I removed the codec entry
> 2. I added "&allowDefaultCodec=false" to disable the adding of the default
> codec
> 3. I added the "myCodecFilter" entry to the filters list
>
> These changes resulted in the following URL:
>
> mina:tcp://{hostname}:{port}?sync=false&minaLogger=true&allowDefaultCodec=false&filters=#sslClientFilter,#myCodecFilter
>
> It all seems to be working correctly now.
>
> Cheers,
>
> Jim
>
>
> On 1/4/13 10:15 AM, James Gough wrote:
>>
>> More data points:
>>
>> -It doesn't matter whether I set the client field to true, it behaves the
>> same way no matter what the field is set to
>>
>> -When I called the "sendMessage" method with the grails routing plugin, it
>> was fine with me passing it a string until I added the SSLFilter, then it
>> threw a ClassCast exception unless I would pass it a Mina ByteBuffer
>>
>> Jim
>>
>> On 1/3/13 9:43 AM, James Gough wrote:
>>>
>>> I'm using Camel 2.9.0 with the Mina 1.x component with the
>>> mina-filter-ssl component imported.  I am using the Grails routing plugin's
>>> sendMessage method to the following URL:
>>>
>>>
>>> "mina:tcp://${hostname}:${port}?sync=false&minaLogger=true&codec=#mycodec&filters=#sslClientFilter"
>>>
>>> The SSLFilter is set up using Spring DSL, the only settings I set for the
>>> filter is to pass a valid SSLContext to it's constructor and setting the
>>> clientMode to true:
>>>
>>>   "sslContextGenerator(com.mypackage.mina.SSLContextGenerator) {
>>>     keyStorePassword = '${keyStorePassword}'
>>>     trustStorePassword = '${trustStorePassword}'
>>>     keyStorePath = '${keyStorePath}'
>>>     trustStorePath = '${trustStorePath}'
>>>   }
>>>
>>>   sslContext(sslContextGenerator: "getSSLContext")
>>>
>>>   sslClientFilter(org.apache.mina.filter.SSLFilter, sslContext) {
>>>     useClientMode = true
>>>   }"
>>>
>>> I have verified that the SSLFilter instance does have the "client"
>>> parameter set to true.
>>>
>>> I'm stumped.  It just seems like when the SSLFilter is engaged it's
>>> behavior is entirely different.
>>>
>>> Jim
>>>
>>>
>>> On 1/3/13 12:01 AM, Claus Ibsen wrote:
>>>>
>>>> Hi
>>>>
>>>> What Camel version are you using?
>>>> And which Camel component are you referring to? Could it be camel-mina
>>>> ? eg the Mina 1.x based component?
>>>> And how have you configured the Camel component/route?
>>>>
>>>>
>>>>
>>>> On Thu, Jan 3, 2013 at 1:11 AM, James Gough <ji...@certifydatasystems.com>
>>>> wrote:
>>>>>
>>>>> I am trying to use SSLFilter with a custom codec, but it appears that
>>>>> my
>>>>> client (for which I have called SSLFilter's "setUseClientMode" method
>>>>> with a
>>>>> setting of true), is calling SSLFilter prior to calling the codec, and
>>>>> it
>>>>> calls the decoder's decode method rather than the encoder's encode
>>>>> method,
>>>>> which is called when sslFilter is not used.
>>>>>
>>>>> It goes something like this:
>>>>>
>>>>> SSLFilter used:
>>>>> caller -> SSLFilter -> codec's decoder.decode() method -> service
>>>>>
>>>>> SSLFilter not used:
>>>>> caller -> codec's encoder.encode() method -> service
>>>>>
>>>>> The codec also is handed an encrypted message, which is useless since I
>>>>> have
>>>>> to do some stuff to it prior to sending it.
>>>>>
>>>>> Any hints?
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Issue with use of SSLFilter with a custom codec

Posted by James Gough <ji...@certifydatasystems.com>.
Solution found (or stumbled upon):

I added the following filter to my resources.groovy file:

myCodecFilter(org.apache.mina.filter.codec.ProtocolCodecFilter, mycodec)

And I changed the URL so that:

1. I removed the codec entry
2. I added "&allowDefaultCodec=false" to disable the adding of the 
default codec
3. I added the "myCodecFilter" entry to the filters list

These changes resulted in the following URL:

mina:tcp://{hostname}:{port}?sync=false&minaLogger=true&allowDefaultCodec=false&filters=#sslClientFilter,#myCodecFilter

It all seems to be working correctly now.

Cheers,

Jim

On 1/4/13 10:15 AM, James Gough wrote:
> More data points:
>
> -It doesn't matter whether I set the client field to true, it behaves 
> the same way no matter what the field is set to
>
> -When I called the "sendMessage" method with the grails routing 
> plugin, it was fine with me passing it a string until I added the 
> SSLFilter, then it threw a ClassCast exception unless I would pass it 
> a Mina ByteBuffer
>
> Jim
>
> On 1/3/13 9:43 AM, James Gough wrote:
>> I'm using Camel 2.9.0 with the Mina 1.x component with the 
>> mina-filter-ssl component imported.  I am using the Grails routing 
>> plugin's sendMessage method to the following URL:
>>
>>  "mina:tcp://${hostname}:${port}?sync=false&minaLogger=true&codec=#mycodec&filters=#sslClientFilter" 
>>
>>
>> The SSLFilter is set up using Spring DSL, the only settings I set for 
>> the filter is to pass a valid SSLContext to it's constructor and 
>> setting the clientMode to true:
>>
>>   "sslContextGenerator(com.mypackage.mina.SSLContextGenerator) {
>>     keyStorePassword = '${keyStorePassword}'
>>     trustStorePassword = '${trustStorePassword}'
>>     keyStorePath = '${keyStorePath}'
>>     trustStorePath = '${trustStorePath}'
>>   }
>>
>>   sslContext(sslContextGenerator: "getSSLContext")
>>
>>   sslClientFilter(org.apache.mina.filter.SSLFilter, sslContext) {
>>     useClientMode = true
>>   }"
>>
>> I have verified that the SSLFilter instance does have the "client" 
>> parameter set to true.
>>
>> I'm stumped.  It just seems like when the SSLFilter is engaged it's 
>> behavior is entirely different.
>>
>> Jim
>>
>>
>> On 1/3/13 12:01 AM, Claus Ibsen wrote:
>>> Hi
>>>
>>> What Camel version are you using?
>>> And which Camel component are you referring to? Could it be camel-mina
>>> ? eg the Mina 1.x based component?
>>> And how have you configured the Camel component/route?
>>>
>>>
>>>
>>> On Thu, Jan 3, 2013 at 1:11 AM, James Gough 
>>> <ji...@certifydatasystems.com> wrote:
>>>> I am trying to use SSLFilter with a custom codec, but it appears 
>>>> that my
>>>> client (for which I have called SSLFilter's "setUseClientMode" 
>>>> method with a
>>>> setting of true), is calling SSLFilter prior to calling the codec, 
>>>> and it
>>>> calls the decoder's decode method rather than the encoder's encode 
>>>> method,
>>>> which is called when sslFilter is not used.
>>>>
>>>> It goes something like this:
>>>>
>>>> SSLFilter used:
>>>> caller -> SSLFilter -> codec's decoder.decode() method -> service
>>>>
>>>> SSLFilter not used:
>>>> caller -> codec's encoder.encode() method -> service
>>>>
>>>> The codec also is handed an encrypted message, which is useless 
>>>> since I have
>>>> to do some stuff to it prior to sending it.
>>>>
>>>> Any hints?
>>>
>>>
>>
>>
>
>


Re: Issue with use of SSLFilter with a custom codec

Posted by James Gough <ji...@certifydatasystems.com>.
More data points:

-It doesn't matter whether I set the client field to true, it behaves 
the same way no matter what the field is set to

-When I called the "sendMessage" method with the grails routing plugin, 
it was fine with me passing it a string until I added the SSLFilter, 
then it threw a ClassCast exception unless I would pass it a Mina ByteBuffer

Jim

On 1/3/13 9:43 AM, James Gough wrote:
> I'm using Camel 2.9.0 with the Mina 1.x component with the 
> mina-filter-ssl component imported.  I am using the Grails routing 
> plugin's sendMessage method to the following URL:
>
>  "mina:tcp://${hostname}:${port}?sync=false&minaLogger=true&codec=#mycodec&filters=#sslClientFilter" 
>
>
> The SSLFilter is set up using Spring DSL, the only settings I set for 
> the filter is to pass a valid SSLContext to it's constructor and 
> setting the clientMode to true:
>
>   "sslContextGenerator(com.mypackage.mina.SSLContextGenerator) {
>     keyStorePassword = '${keyStorePassword}'
>     trustStorePassword = '${trustStorePassword}'
>     keyStorePath = '${keyStorePath}'
>     trustStorePath = '${trustStorePath}'
>   }
>
>   sslContext(sslContextGenerator: "getSSLContext")
>
>   sslClientFilter(org.apache.mina.filter.SSLFilter, sslContext) {
>     useClientMode = true
>   }"
>
> I have verified that the SSLFilter instance does have the "client" 
> parameter set to true.
>
> I'm stumped.  It just seems like when the SSLFilter is engaged it's 
> behavior is entirely different.
>
> Jim
>
>
> On 1/3/13 12:01 AM, Claus Ibsen wrote:
>> Hi
>>
>> What Camel version are you using?
>> And which Camel component are you referring to? Could it be camel-mina
>> ? eg the Mina 1.x based component?
>> And how have you configured the Camel component/route?
>>
>>
>>
>> On Thu, Jan 3, 2013 at 1:11 AM, James Gough 
>> <ji...@certifydatasystems.com> wrote:
>>> I am trying to use SSLFilter with a custom codec, but it appears 
>>> that my
>>> client (for which I have called SSLFilter's "setUseClientMode" 
>>> method with a
>>> setting of true), is calling SSLFilter prior to calling the codec, 
>>> and it
>>> calls the decoder's decode method rather than the encoder's encode 
>>> method,
>>> which is called when sslFilter is not used.
>>>
>>> It goes something like this:
>>>
>>> SSLFilter used:
>>> caller -> SSLFilter -> codec's decoder.decode() method -> service
>>>
>>> SSLFilter not used:
>>> caller -> codec's encoder.encode() method -> service
>>>
>>> The codec also is handed an encrypted message, which is useless 
>>> since I have
>>> to do some stuff to it prior to sending it.
>>>
>>> Any hints?
>>
>>
>
>


Re: Issue with use of SSLFilter with a custom codec

Posted by James Gough <ji...@certifydatasystems.com>.
I'm using Camel 2.9.0 with the Mina 1.x component with the 
mina-filter-ssl component imported.  I am using the Grails routing 
plugin's sendMessage method to the following URL:

  "mina:tcp://${hostname}:${port}?sync=false&minaLogger=true&codec=#mycodec&filters=#sslClientFilter"

The SSLFilter is set up using Spring DSL, the only settings I set for 
the filter is to pass a valid SSLContext to it's constructor and setting 
the clientMode to true:

   "sslContextGenerator(com.mypackage.mina.SSLContextGenerator) {
     keyStorePassword = '${keyStorePassword}'
     trustStorePassword = '${trustStorePassword}'
     keyStorePath = '${keyStorePath}'
     trustStorePath = '${trustStorePath}'
   }

   sslContext(sslContextGenerator: "getSSLContext")

   sslClientFilter(org.apache.mina.filter.SSLFilter, sslContext) {
     useClientMode = true
   }"

I have verified that the SSLFilter instance does have the "client" 
parameter set to true.

I'm stumped.  It just seems like when the SSLFilter is engaged it's 
behavior is entirely different.

Jim


On 1/3/13 12:01 AM, Claus Ibsen wrote:
> Hi
>
> What Camel version are you using?
> And which Camel component are you referring to? Could it be camel-mina
> ? eg the Mina 1.x based component?
> And how have you configured the Camel component/route?
>
>
>
> On Thu, Jan 3, 2013 at 1:11 AM, James Gough <ji...@certifydatasystems.com> wrote:
>> I am trying to use SSLFilter with a custom codec, but it appears that my
>> client (for which I have called SSLFilter's "setUseClientMode" method with a
>> setting of true), is calling SSLFilter prior to calling the codec, and it
>> calls the decoder's decode method rather than the encoder's encode method,
>> which is called when sslFilter is not used.
>>
>> It goes something like this:
>>
>> SSLFilter used:
>> caller -> SSLFilter -> codec's decoder.decode() method -> service
>>
>> SSLFilter not used:
>> caller -> codec's encoder.encode() method -> service
>>
>> The codec also is handed an encrypted message, which is useless since I have
>> to do some stuff to it prior to sending it.
>>
>> Any hints?
>
>


Re: Issue with use of SSLFilter with a custom codec

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

What Camel version are you using?
And which Camel component are you referring to? Could it be camel-mina
? eg the Mina 1.x based component?
And how have you configured the Camel component/route?



On Thu, Jan 3, 2013 at 1:11 AM, James Gough <ji...@certifydatasystems.com> wrote:
> I am trying to use SSLFilter with a custom codec, but it appears that my
> client (for which I have called SSLFilter's "setUseClientMode" method with a
> setting of true), is calling SSLFilter prior to calling the codec, and it
> calls the decoder's decode method rather than the encoder's encode method,
> which is called when sslFilter is not used.
>
> It goes something like this:
>
> SSLFilter used:
> caller -> SSLFilter -> codec's decoder.decode() method -> service
>
> SSLFilter not used:
> caller -> codec's encoder.encode() method -> service
>
> The codec also is handed an encrypted message, which is useless since I have
> to do some stuff to it prior to sending it.
>
> Any hints?



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: cibsen@redhat.com
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen