I have been trying to figure this one out for days. I need to know if cfhttp 
works with https for Cold Fusion ver 8.01. I've searched the internet with no 
definitive answers. Below I have included some code that should work but it is 
not. 

It works when I change the url to http instead of https. I have substituted the 
domain names so please try this code with a known https address if you like.

I have tried many things like installing the cert to the server cert store, 
other usernames etc..

Hopefully someone out there has been successful in logining into a website that 
uses SSL for the login page. Chances are this could simply be a firewall thing 
I just don't know. I'm holding out for a hero...

Here's the code:

<!---Get remote cookie--->
<cfhttp url="https://www.somedomain.com/servlet/loginapp.Login?lang=ENG"; 
method="GET" useragent="#CGI.HTTP_USER_AGENT#"></cfhttp>

<cfset headers = cfhttp.header>
<cfset cookies = getCookies(cfhttp.header)>

<!--- perform login --->
<cfhttp url="https://www.somedomain.com/servlet/loginapp.ProcessLogin"; 
method="POST" useragent="#CGI.HTTP_USER_AGENT#" resolveurl="yes">
        <cfloop from="1" to="#arrayLen(cookies)#" step="1" index="i">
                <cfhttpparam type="cookie" name="#cookies[i].NAME#" 
value="#cookies[i].VALUE#">
        </cfloop>
    <cfhttpparam type="FORMFIELD" name="USERNAME" value="John Smith">
    <cfhttpparam type="FORMFIELD" name="PASSWORD" value="Password">
</cfhttp>

<cffunction name="getCookies" output="false" returnType="array">
        <cfargument name="headers" type="String" required="yes">
        
        <cfset var cookies = arrayNew(1)>
        <cfset var thisCookie = StructNew()>
        <cfset var header = "">
        <cfset var aCookie = "">
        <cfset var crumb = "">
        <cfset var paramName = "">
        <cfset var paramValue = "">
        
        <cfloop list="#headers#" delimiters="#Chr(10)#" index="header">
                <cfif reFind("^Set-Cookie: ", header) gt 0>
                        <cfset acookie = reReplace(header,"^Set-Cookie: 
","","ALL")>
                        <Cfset thisCookie = StructNew()>
                        <cfloop list="#acookie#" delimiters=";" index="crumb">
                                <cfset crumb = trim(crumb)>
                                <cfset paramName = listgetat(crumb,1,"=")>
                                <cfset paramValue = listgetat(crumb,2,"=")>
                                <cfif paramName eq "expires">
                                        <cfset thisCookie.expires = paramValue>
                                <cfelseif paramName eq "path">
                                        <cfset thisCookie.path = paramValue>
                                <cfelseif paramName eq "domain">
                                        <cfset thisCookie.domain = paramValue>
                                <cfelseif paramName eq "secure">
                                        <cfset thisCookie.secure = paramValue>
                                <cfelse>
                                        <cfset thisCookie.name = paramName>
                                        <cfset thisCookie.value = paramValue>
                                </cfif>
                        </cfloop>
                        <cfset arrayAppend(cookies,thisCookie)>
                </cfif>
        </cfloop>
        <cfreturn cookies>
</cffunction> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;203748912;27390454;j

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:311529
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

Reply via email to