HitAWallAgain
HitAWallAgain

Reputation: 1

CFHTTP HTTPS Connection Failure CF8

I wrote a simple application to test a RESTful API (provided by an accounting application). I have installed "Poster" in Firefox to test "GET and POST" XML and the API is behaving as it should. I wrote a simple "GET" test page to call the API from within the test CF8 application and the API returned the results I expected. I cannot POST from within the test CF8 application.

I have inserted the following into my application.cfm:

<!--- fix for HTTPS connection failures --->
<cfif NOT isDefined("Application.sslfix")>
    <cfset objSecurity = createObject("java", "java.security.Security") />
    <cfset objSecurity.removeProvider("JsafeJCE") />
    <cfset Application.sslfix = true />
</cfif>

This is the code that is failing:

<cfprocessingdirective suppressWhiteSpace = "Yes">    
    <cfxml variable="customerxml">
        <?xml version="1.0" encoding="UTF­8" standalone="yes"?>
        <dataentry>
            <interface name="Customer Edit"></interface>
            <entity>
                <attribute name="Customer Code">REP003</attribute>
                <attribute name="Customer Name">Repsol3</attribute>
                <attribute name="Address Line 1">El House</attribute>
                <attribute name="Address Line 2">El Street</attribute>
                <attribute name="Address Line 3">El Town</attribute>
            </entity>
        </dataentry>
    </cfxml>
</cfprocessingdirective>

<cfhttp 
    method="post" 
    url="https://***/wsapi/1.1/dataentry/"
    username="***"
    password="***"
    charset="utf-8">
    <cfhttpparam type="header" name="Accept-Encoding" value="*" />
    <cfhttpparam type="header" name="TE" value="deflate;q=0" />
    <cfhttpparam type="header" name="Content-Type" value="application/xml" />
    <cfhttpparam name="XML_Test" type="xml" value="#customerxml#">
</cfhttp> 

There's a lot published on this topic and I have tried most things but some of the posts are about even older CF versions than mine! Any up-to-date help appreciated.

Upvotes: 0

Views: 2010

Answers (2)

Matthew Friedman
Matthew Friedman

Reputation: 491

Here is a great step by step instructions on how to install self-signed certs or other ssl certs that the Java library does not have installed.

http://www.coldfusioncookbook.com/entries/How-Do-I-Consume-SSL-Encrypted-Content-with-CFHTTP.html

Has helped me out a 1000 times. Matt

Upvotes: 0

Miguel-F
Miguel-F

Reputation: 13548

From the comments

The first thing that I try when receiving a connection failure using <cfhttp> is to verify that you can navigate to the URL using a browser from your ColdFusion server. If that request does not work then it will not work from the ColdFusion call either. Get that issue resolved first before proceeding.

Another common issue when connecting to secure sites using SSL (HTTPS) is that the certificate is not trusted or not known to ColdFusion (Java). In these cases you need to import their certificate into the Java keystore that is in use for ColdFusion.

Upvotes: 2

Related Questions