You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "anish.somadevan" <ne...@gmail.com> on 2015/08/30 23:42:41 UTC

PEM File for Authentication in route

I have a route where i need to make a GET request to an API which is hosted
on a server. The authentication is done using a PEM file. Is there a way i
can include PEM file foe authentication in my route? I need to do this in
Spring DSL XML. Can anyone please let me know if this is possible?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
This is the route XML am using,

<routes xmlns="http://camel.apache.org/schema/spring">
<sslContextParameters id="sslContextParameters">
    <keyManagers keyPassword="keyPassword">
      <keyStore resource="/home/cert.PEM" password="keyStorePassword" />
</keyManagers>
  </sslContextParameters>
<route id="callTokenService">
        <from uri="direct:inter1" />

<setBody>
<convertBodyTo type="java.lang.String" />
<xpath resultType="java.lang.String">/message/Requestdata/text()</xpath>   
</setBody>

<route id="API">
        <from uri="direct:inter1" />
        
        <log message="Message Body ${body}" loggingLevel="INFO" />

<to
uri="https4://somedomain.com:443/topic?sslContextParametersRef=sslContextParameters"
/>

<to uri="direct:inter2" />
</route>

<route id="ParseResponse">
<from uri="direct:inter2"/ >

<to uri="endpoint"/ >
    </route>
</routes>





--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771146.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by Raul Kripalani <ra...@evosent.com>.
1. sslContextParameters is a component option, which means you need to
configure it in the component, not in the endpoint.

<bean class="org.apache.camel.component.http4.HttpComponent">
    <property name="sslContextParameters" ref="..." />
</bean>

2. I don't think the <routes /> element supports nesting the
<sslContextParameters /> element. Note how it is configured here [1].

[1] https://camel.apache.org/camel-configuration-utilities.html

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Wed, Sep 2, 2015 at 11:09 PM, anish.somadevan <ne...@gmail.com> wrote:

> Am not able to make any progress beyond this. Can you please let me know if
> there is anything that am missing in my implementation?
>
> Thanks,
> Anish
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771180.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
Am trying to declare a bean and call its method. I have added this in my
route now,

<bean ref="org.apache.camel.component.http4.HttpComponent"
method="createConfiguration" >
</bean>

I get the following error,
Exhausted after delivery attempt: 1 caught:
org.apache.camel.InvalidPayloadException: No body available of type:
java.io.InputStream but has value:
org.apache.camel.impl.MappedEndpointConfiguration@44931409 of type:
org.apache.camel.impl.MappedEndpointConfiguration on: Message:
org.apache.camel.impl.MappedEndpointConfiguration@44931409. Caused by: No
type converter available to convert from type:
org.apache.camel.impl.MappedEndpointConfiguration to the required type:
java.io.InputStream with value
org.apache.camel.impl.MappedEndpointConfiguration@44931409.
Exchange[Message:
org.apache.camel.impl.MappedEndpointConfiguration@44931409]. Caused by:
[org.apache.camel.NoTypeConversionAvailableException - No type converter
available to convert from type:
org.apache.camel.impl.MappedEndpointConfiguration to the required type:
java.io.InputStream with value
org.apache.camel.impl.MappedEndpointConfiguration@44931409]:
org.apache.camel.InvalidPayloadException: No body available of type:
java.io.InputStream but has value:
org.apache.camel.impl.MappedEndpointConfiguration@44931409 of type:
org.apache.camel.impl.MappedEndpointConfiguration on: Message:
org.apache.camel.impl.MappedEndpointConfiguration@44931409. Caused by: No
type converter available to convert from type:
org.apache.camel.impl.MappedEndpointConfiguration to the required type: 

Can you please let me know which method should i use in the bean and how to
pass parameters to it from my route?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771359.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
When i have SSLContext parameters before the routes tag,I get the below
mentioned error,

exception: unexpected element (uri:"http://camel.apache.org/schema/spring",
local:"sslContextParameters"). Expected elements are
<{http://camel.apache.org/schema/spring}aggregate>,<{http://camel.apache.org/schema/spring}aop>,<{http://camel.apache.org/schema/spring}avro>,<{http://camel.apache.org/schema/spring}base64>,<{http://camel.apache.org/schema/spring}batchResequencerConfig>,<{http://camel.apache.org/schema/spring}bean>,<{http://camel.apache.org/schema/spring}beanio>,<{http://camel.apache.org/schema/spring}bindy>,<{http://camel.apache.org/schema/spring}castor>,<{http://camel.apache.org/schema/spring}choice>,<{http://camel.apache.org/schema/spring}constant>,<{http://camel.apache.org/schema/spring}contextScan>,<{http://camel.apache.org/schema/spring}convertBodyTo>,<{http://camel.apache.org/schema/spring}crypto>,<{http://camel.apache.org/schema/spring}csv>,<{http://camel.apache.org/schema/spring}customDataFormat>,<{http://camel.apache.org/schema/spring}customLoadBalancer>,<{http://camel.apache.org/schema/spring}dataFormats>,<{http://camel.apache.org/schema/spring}delay>,<{http://camel.apache.org/schema/spring}description>,<{http://camel.apache.org/schema/spring}doCatch>,<{http://camel.apache.org/schema/spring}doFinally>,<{http://camel.apache.org/schema/spring}doTry>,<{http://camel.apache.org/schema/spring}dynamicRouter>,<{http://camel.apache.org/schema/spring}el>,<{http://camel.apache.org/schema/spring}enrich>,<{http://camel.apache.org/schema/spring}expression>,<{http://camel.apache.org/schema/spring}expressionDefinition>,<{http://camel.apache.org/schema/spring}failover>,<{



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771352.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by yogu13 <yo...@gmail.com>.
Hello Anish,

When you tried the SSLContextParameters tag outside the routes tag what was
the error ?

Regards,
-Yogesh



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771322.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by Raul Kripalani <ra...@evosent.com>.
Please create a Github repo or Gist with your code so we can assist you
better.

Thanks,

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Tue, Sep 8, 2015 at 7:04 AM, anish.somadevan <ne...@gmail.com> wrote:

> I tried having the SSLContextParameters tag outside the routes tag, but it
> resulted in error. Seems like routes tag should be the first node in XML.
> Also, i had checked the blueprint schema and found that
> SSLContextParameters
> bean is referred in this schema, but not in spring schema
> (http://camel.apache.org/schema/) Does this have anything to do with the
> bean not being referenced? I tried having blueprint as the namespace in my
> routes tag, but it resulted in error expecting spring schema.
>
> Thanks,
> Anish
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771321.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
I tried having the SSLContextParameters tag outside the routes tag, but it
resulted in error. Seems like routes tag should be the first node in XML.
Also, i had checked the blueprint schema and found that SSLContextParameters
bean is referred in this schema, but not in spring schema
(http://camel.apache.org/schema/) Does this have anything to do with the
bean not being referenced? I tried having blueprint as the namespace in my
routes tag, but it resulted in error expecting spring schema.

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771321.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
I tried having the sslContextPArameters tag outside the routes tag, but that
didn't help either. I now have my route as given below,

    <route id="parseJSON">
        <from uri="direct:inter2" />

<sslContextParameters id="SSLContextParameters">
    <keyManagers>
      <keyStore resource="/home/cert.pfx" password="********" />
</keyManagers>
</sslContextParameters>

<setHeader headerName="CamelHttpMethod">
        <constant>GET</constant>
    </setHeader>
<setHeader headerName="Authorization">
<constant>Basic YWRtaW46dGVzdHBhc3M=</constant>
</setHeader>
<to uri="https4://somedomain.com/tenants?SSLContextParameters"/>


And i get this error,

Exhausted after delivery attempt: 1 caught:
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated:
javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
	at com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(Unknown
Source) [jsse.jar:1.6]






--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771280.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
I have updated my route as follows, 

   <route id="API">
        <from uri="direct:inter2" />

<sslContextParameters id="Mysslcontext">
    <keyManagers keyPassword="keyPassword">
      <keyStore resource="/home/key.jks" password="keyStorePassword" />
</keyManagers>
  </sslContextParameters>

<bean beanType="org.apache.camel.component.http4.HttpComponent"
method="createEndpoint">
<property name="sslContextParameters" ref="Mysslcontext" />
</bean>

<setHeader headerName="CamelHttpMethod">
        <constant>GET</constant>
    </setHeader>

<to uri="https4://somedomain.com/tenants" />

I get a different error now, 

java.net.URISyntaxException: Illegal character in path at index 0:
org.apache.camel.impl.DefaultComponent.createEndpoint(java.lang.String)
throws java.lang.Exception]. Exchange[Message:
<CamelData><Requestdata/><Provider/><ClientID/></CamelData>: 

For some reason the input XML message is being printed as URI instead of
taking it from the <to uri>

Can you please let me know if am on right track in terms of implementation,
and how to resolve this error? 

Thanks, 
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771227.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
I have updated my route as follows,

   <route id="parseJSON">
        <from uri="direct:inter2" />

lContextParameters id="Mysslcontext">
    <keyManagers keyPassword="keyPassword">
      <keyStore
resource="/home/ENV8C/anish.somadevan/keystore_iapiclient-cpo.acp.env1.acp.aws.accenture.com.jks"
password="keyStorePassword" />
</keyManagers>
  </sslContextParameters>

<bean beanType="org.apache.camel.component.http4.HttpComponent">
<property name="sslContextParameters" ref="Mysslcontext" />
</bean>

<setHeader headerName="CamelHttpMethod">
        <constant>GET</constant>
    </setHeader>

<to uri="https4://somedomain.com/tenants" />

I get a different error now,

Exhausted after delivery attempt: 1 caught:
org.apache.camel.component.bean.AmbiguousMethodCallException: Ambiguous
method invocations possible: [public org.apache.camel.EndpointConfiguration
org.apache.camel.impl.DefaultComponent.createConfiguration(java.lang.String)
throws java.lang.Exception, public org.apache.camel.Endpoint
org.apache.camel.impl.DefaultComponent.createEndpoint(java.lang.String)
throws java.lang.Exception]. Exchange[Message: 

Can you please let me know if am on right track in terms of implementation,
and how to resolve this error?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771226.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
Am not able to make any progress beyond this. Can you please let me know if
there is anything that am missing in my implementation?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771180.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
Thanks for your suggestion. Am using PEM file for authentication purpose. I
did try using the Http4 component with SSLContextParameters as given below,

<route id="API">
        <from uri="direct:inter3" />

        <log message="Message Body ${body}" loggingLevel="INFO" />
<setBody>
<simple>${body}</simple>
</setBody>

<sslContextParameters
      id="sslContextParameters">
    <keyManagers>
      <keyStore
          resource="/home/Auth/file.PEM"/>
    </keyManagers>
  </sslContextParameters>

<to
uri="https4://somedomain.com:443/topic?sslContextParametersRef=sslContextParameters"
/>

But i get an error,

JmsConsumer[ISEEOutboundQueue]) CamelOutboundAdapter exception: Failed to
create route JSON-XML at: >>>
To[https4://somedomain.com:443/topic?sslContextParametersRef=sslContextParameters]
<<< in route: Route[[From[direct:inter3]] -> [Log[Message Body ${body}],
S... because of Failed to resolve endpoint:
https4://somedomain.com:443/topic?sslContextParametersRef=sslContextParameters
due to: No bean could be found in the registry for: sslContextParameters of
type: org.apache.camel.util.jsse.SSLContextParameters

Am using Camel 2.10.3 JAR. Can you please let me know if am missing anything
here?

Thanks,
Anish





--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771109.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by Raul Kripalani <ra...@evosent.com>.
It depends on what your PEM file contains and what the server is requesting
of you.

The PEM file may contain a private key for client SSL authentication, in
which case you need to use the camel-http4 [1] sslContextParameters option
to configure the keystore, key alias, keystore passwd, key passwd, etc.
using the Camel JSSE Configuration Utility (modelled after CXF SSL config
approach) as indicated in [2].

If the PEM file contains a certificate for the remote server which you need
to trust, then you're probably better off adding it to your server's
truststore and using the JVM options to pass in the location, password,
etc. If you don't want to add the certificate to the server-wide
truststore, you may use the JSSE Config Utility to configure it separately
in this particular endpoint.

[1] https://camel.apache.org/http4.html
[2]
https://camel.apache.org/http4.html#HTTP4-UsingtheJSSEConfigurationUtility

*Raúl Kripalani*
Apache Camel PMC Member & Committer | Enterprise Architect, Open Source
Integration specialist
http://about.me/raulkripalani | http://www.linkedin.com/in/raulkripalani
http://blog.raulkr.net | twitter: @raulvk

On Mon, Aug 31, 2015 at 11:47 PM, anish.somadevan <ne...@gmail.com>
wrote:

> Am trying to use Http4 or SSH components. Can you please let me know how to
> resolve this issue using these components?
>
> Thanks,
> Anish
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771107.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
Am trying to use Http4 or SSH components. Can you please let me know how to
resolve this issue using these components?

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771107.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
I assume you are speaking about the components such as Jetty. Am not using
any of these. I believe you can understand better if i paste the route am
using,

<recipientList>
<simple>https://{{value}}.domain.net:443/${header.Topic}/messages</simple>
</recipientList>





--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771091.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by Raul Kripalani <ra...@evosent.com>.
Yes, but which component exactly? We have many for the HTTP transport.
On 31 Aug 2015 00:31, "anish.somadevan" <ne...@gmail.com> wrote:

> Its a HTTPS call, and am using recipeintList coz i need to construct
> dynamic
> URI. Also, due to some compatibility issues i can use only 2.10.3 version
> camel JARs.
>
> Thanks,
> Anish
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771089.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>

Re: PEM File for Authentication in route

Posted by "anish.somadevan" <ne...@gmail.com>.
Its a HTTPS call, and am using recipeintList coz i need to construct dynamic
URI. Also, due to some compatibility issues i can use only 2.10.3 version
camel JARs.

Thanks,
Anish



--
View this message in context: http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084p5771089.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: PEM File for Authentication in route

Posted by Raul Kripalani <ra...@evosent.com>.
I assume this is an HTTP call. Which component are you using in your
producer endpoint?

Raúl.
On 30 Aug 2015 22:42, "anish.somadevan" <ne...@gmail.com> wrote:

> I have a route where i need to make a GET request to an API which is hosted
> on a server. The authentication is done using a PEM file. Is there a way i
> can include PEM file foe authentication in my route? I need to do this in
> Spring DSL XML. Can anyone please let me know if this is possible?
>
> Thanks,
> Anish
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/PEM-File-for-Authentication-in-route-tp5771084.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>