Search code examples
jsonoauthcoldfusionflickr

Coldfusion cfhttp returning peer not authenticated


I'm attempting to use Coldfusion (Coldfusion 8) to get a user's authentication token from Flickr using their API. I've already written a bit to get the necessary from token, which is returned as a query string. Now, I'm using the following code to attempt to receive the JSON response, which contains the user's data. and would be replaced by the key and secret for my Flickr app.

<cfif structKeyExists(URL,"frob")>
    <cfset apiKey =  "<myapikey>" />
    <cfset apiSecret =  "<myapisecret>" />
    <cfset frob = #URL.frob# />
    <cfset apiSig = Hash(apiSecret & "api_key" & apiKey & "formatjson" & "frob" & frob & "methodflickr.auth.getTokenpermsread", "MD5") />
    <cfset flickrUrl = "https://flickr.com/services/rest/?method=flickr.auth.getToken&api_key=" & apiKey & "&perms=read" & "&format=json" & "&frob=" & frob & "&api_sig=" & apiSig />
    <cflocation url = "#flickrUrl#" addToken = "false" />
    <cfhttp
      method = "GET"
      url = "#flickrUrl#"
      resolveurl = "Yes"
      result = "result" />
    <cfdump var = "#result#" />
</cfif>

However, the cfdump just says peer not authenticated. I am able to use cflocation as follows to view the JSON data I should be receiving, but I don't know how to access it and parse it using Coldfusion.

<cflocation url = "#flickrUrl#" addToken = "false" />

Solution

  • Have you installed the flickr certificate in your Java keystore?

    Adobe ColdFusion documentation:

    For secure connections to remote servers over SSL, all current versions of ColdFusion require the remote system's SSL certificate to exist in ColdFusion's certificate truststore.

    https://helpx.adobe.com/coldfusion/kb/import-certificates-certificate-stores-coldfusion.html

    Also, before installing the flickr certificate, you need to download it. You can use Chrome for this:

    1. Open flickr in Chrome
    2. Click on the lock icon in the address bar
    3. Click Connections
    4. Click Certificate Information For Macs you can just grab the cert to your desktop with the mouse, for Windows its Details tab and "Copy to File"...

    Once you have the cert, you need to import cert to the keystore. You need to locate your JVM used by your ColdFusion installation and import it there. Java keytool commands vary depending on version, but even CF documents it pretty well:

    https://helpx.adobe.com/coldfusion/kb/import-certificates-certificate-stores-coldfusion.html

    Oh and of course, do not forget to restart your ColdFusion Server after import...