cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1425
Views
0
Helpful
4
Replies

skip hostname validation in httpmethod

vijjadha
Cisco Employee
Cisco Employee

Hi,

I am working on a UCSD integration with a custom Web service using Rest API. The target rest server is running on IIS on windows 2012r2.

It has a selfsigned certificate generated for the computer host name. However the web service running on that server is published using a different host header (other than the hostname) and is only accessible via host header.

E.g hostheader : mylab

       hostname: my_lab.mydom.local

The api can be called  through postman after ignoring the ssl warnings. However, we are not able to make a successful connection via cloupia script. We used fiddler to capture the error and found that it is because of hostname mismatch. (we are calling the web service using host header but the certificate is assigned to hostname). We need help in bypassing the hostname validation since this is a lab environment.

Any help will be appreciated.

Following is a sample code we are using:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------@@@@@@@@

var httpsClient = CustomEasySSLSocketFactory.getIgnoreSSLClient("vmclab","443");

    httpsClient.getParams().setCookiePolicy("default");

    httpsClient.getParams().setAuthenticationPreemptive(true);

    var tableURL = "/APP/APIs/VMName/VMName.php"

    var httpMethod = new PostMethod(tableURL);

     httpsClient.executeMethod(httpMethod);

    if (statuscode != 200)

    {

        logger.addError("Unable to get the sys_id from the Service Request HTTP response code: " + statuscode);

        logger.addError("Response = "+httpMethod.getResponseBodyAsString());

         httpMethod.releaseConnection();

        // Set this task as failed.

        ctxt.setFailed("Request failed.");

        ctxt.exit()

    } else {

        var responseBody = String(httpMethod.getResponseBodyAsString());

        //logger.addInfo("REST API Executed successfully, RAW result: " + responseBody);

        return responseBody;

    }

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

and

this is the exact error

java.lang.RuntimeException: java.net.SocketException: Connection reset, selectedContext=<None>

1 Accepted Solution

Accepted Solutions

vijjadha
Cisco Employee
Cisco Employee

This problem was solved by changing the certificate on the REST target to match the hostname which were using in the cloupia script.

View solution in original post

4 Replies 4

Orf Gelbrich
Cisco Employee
Cisco Employee

I would use VIX or powershell to change your web service

Hi Orf,

Thanks for your reply. The web service is hosted and maintained by customer and we do not have access to modify the same.

We just need a workaround time being to avoid hostname validation. I did search online for this and there seems to be a way to do this but I am unable to get exact syntax for this.

Thanks,

Vijay

I am not sure how I can help you with an external system syntax problem.

vijjadha
Cisco Employee
Cisco Employee

This problem was solved by changing the certificate on the REST target to match the hostname which were using in the cloupia script.

Review Cisco Networking for a $25 gift card

Cisco UCS X-Series Energy Efficiency Offer