To Invoke Mutual SSL Enabled endpoint in WSO2 EI 6.4.0

80 Views Asked by At

I am trying Mutual SSL in WSo2 EI by following exact steps mentioned in this blog

WSO2 EI acts as client and Axis2server is backend

All Pre-requisites mentioned in this blog done and detailed steps are in another raised questions.

  • Axis2Server started
  • WSO2 EI Server Started

Pass through Proxy Service:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SSLStockQuoteProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <outSequence>
         <send/>
      </outSequence>
      <endpoint>
         <address uri="https://axis2.backend.mytest:9002/services/SimpleStockQuoteService"/>
      </endpoint>
   </target>
   <description/>
</proxy>
                            

Invoke the SSLStockQuoteProxy service using a axis2 client

Executed below command at <EI_HOME>/samples/axis2Client/ directory

C:\mutualssl\wso2axis2-6.4.0\wso2ei-6.4.0\samples\axis2Client>ant stockquote -Daddurl=http://localhost:8280/services/SSLStockQuoteProxy

The above command gives me result like below in same axis2 client

result

My Concern here is that if i invoke this proxy service via Try this Service tool below ERROR response i got.

proxy call

I tested via API calls also.

API Code:

<api xmlns="http://ws.apache.org/ns/synapse" name="mutualsslapi" context="/mutualsslapi">
   <resource methods="GET">
      <inSequence>
         <log level="custom">
            <property name="INFO:" value="Hit received in Mutualssl API"/>
         </log>
         <call>
            <endpoint>
               <address uri="https://axis2.backend.mytest:9002/services/SimpleStockQuoteService"/>
            </endpoint>
         </call>
         <respond/>
      </inSequence>
      <outSequence/>
      <faultSequence>
         <log level="custom">
            <property name="ERROR_MESSAGE:::: " expression="get-property('ERROR_MESSAGE')"/>
         </log>
         <makefault version="soap11">
            <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:Client"/>
            <reason expression="$ctx:ERROR_MESSAGE"/>
            <role/>
         </makefault>
         <send/>
      </faultSequence>
   </resource>
</api>
                    

API Hit via postman: postman

WSO2 Logs:

[2023-04-05 22:11:00,948] []  INFO - LogMediator INFO: = Hit received in Mutualssl API

Apart from this, nothing printed in Logs when I invoke above mentioned API.

If mutual SSL is enabled, then that mutual ssl enabled endpoint (axis2 services ) call should happen right?

How to Test this Mutual SSL Flow?

2

There are 2 best solutions below

2
ycr On BEST ANSWER

Yes the call should go through if you have all the certificates in place. Your issue is you are not sending the correct Payload or the correct SOAPAction with the request. Which is mandatory if you are doing Soap calls. You can add the correct SOAP header like below before doing the call. Also make sure you send a proper payload to the backend.

<header name="Action" value="urn:getQuote" />
0
Justin On

As per suggestion given by @ycr, I have tried the above mentioned Axis2Service in SOAP UI

Axis2 backend WSDL URL: (wsdl accessed via http not https) http://axis2.backend.mytest:9000/services/SimpleStockQuoteService?wsdl

Sample Request mentioned below found from this blog or wso2 doc

<m:getQuote xmlns:m="http://services.samples/xsd">
    <m:request>
        <m:symbol>IBM</m:symbol>
    </m:request>
</m:getQuote>

SOAP Action:

<header name="Action" scope="default" value="urn:getQuote"/>

via SOAP UI:

SOAP UI

SSLStockQuoteProxy via try this service tool:

proxy

Remodified API code:

<api xmlns="http://ws.apache.org/ns/synapse" name="mutualsslapi" context="/mutualsslapi">
   <resource methods="POST">
      <inSequence>
         <log level="custom">
            <property name="INFO:" value="Hit received in Mutualssl API"/>
         </log>
         <property name="companyName" expression="json-eval($.companyName)" scope="default" type="STRING"/>
         <payloadFactory media-type="xml">
            <format>
               <m0:getQuote xmlns:m0="http://services.samples">
                  <m0:request>
                     <m0:symbol>$1</m0:symbol>
                  </m0:request>
               </m0:getQuote>
            </format>
            <args>
               <arg evaluator="xml" expression="get-property('companyName')"/>
            </args>
         </payloadFactory>
         <header name="Action" scope="default" value="urn:getQuote"/>
         <call>
            <endpoint>
               <address uri="https://axis2.backend.mytest:9002/services/SimpleStockQuoteService"/>
            </endpoint>
         </call>
         <log level="custom">
            <property name="RESPOSNE::::: " expression="$body"/>
         </log>
         <respond/>
      </inSequence>
      <outSequence/>
      <faultSequence>
         <log level="custom">
            <property name="ERROR_MESSAGE:::: " expression="get-property('ERROR_MESSAGE')"/>
         </log>
         <makefault version="soap11">
            <code xmlns:soap11Env="http://schemas.xmlsoap.org/soap/envelope/" value="soap11Env:Client"/>
            <reason expression="$ctx:ERROR_MESSAGE"/>
            <role/>
         </makefault>
         <send/>
      </faultSequence>
   </resource>
</api>
                    

via postman(API hit):

API hit