Ryan Ternier
Ryan Ternier

Reputation: 8804

Apache Camel, Client Certificates

I'm trying to find an elegant way to attach client certificates through Apache Camel. It can either be in Java or Spring XML.

The servers I'm sending to all have server cert's which would encrypt the traffic, but I need to attach the client public certificate to the message before sending. The server contains 15 or so certificates with their corresponding private keys.

My main configuration is written in Spring XML, so I'm not sure how to get that working with adding client certificates.

(I'm a .NET guy with minimal java and 0 Linux experience)

Sample Spring:

<camel:route>          
    <camel:from uri="direct:GetEligibility"/>
    <camel:doTry>                   
        <camel:choice>
            <camel:when>
                <camel:xpath>count(//soapenv:Envelope) = '0'</camel:xpath>
                <camel:to uri="xslt:xslt/WrapSoap.xsl"/>
            </camel:when>
        </camel:choice>   
        <camel:setHeader headerName="CamelHttpMethod">
            <camel:constant>POST</camel:constant>
        </camel:setHeader>

        <camel:setHeader headerName="Content-Type">
            <camel:constant>text/xml; charset=utf-8</camel:constant>
        </camel:setHeader>     

        <camel:to uri="https://testsite.gov.ca/Services.Secured/FICR_AR022001.asmx"/>        

        <camel:doCatch>
            <camel:exception>java.lang.Exception</camel:exception>
            <camel:bean ref="log" method="error"/>
        </camel:doCatch>
    </camel:doTry>                
</camel:route>    

Upvotes: 2

Views: 4238

Answers (1)

Petter Nordlander
Petter Nordlander

Reputation: 22279

You need to preconfigure a set of SSLContextParameters and then you can add whichever certificate you want to the http endpoint. You can have a choice to route to different endpoints with different certificates.

It's described in the Camel docs here:

Upvotes: 1

Related Questions