Remote Object for both HTTPS and HTTP
One of my main Flex projects is a content management system. It is continually being developed and is in production as my employer’s backend. I hope to make it an even more usable CMS solution by making it where it can be deployed for other websites.
With that future goal in mind, I needed to revisit my services-config.xml file. I use AMFPHP and had previously hardcoded the endpoint. We use SSL because the backend is used for more than just editing web pages. So for it to work on another site, I would needed to edit the services-config.xml file and recompile.
I did a google search on services-config secure and found this page which was very helpful. This page was also an interesting read. Before reading these, I did not know you could use the tokens {server.name} and {server.port} in your services-config.xml file.
Here is my new services-config.xml file that will use SSL if the page is using SSL and regular HTTP if it is not. I verified it was indeed using SSL with Charles.
-
<?xml version="1.0" encoding="UTF-8"?>
-
<services-config>
-
<services>
-
<service id="amfphp-flashremoting-service" class="flex.messaging.services.RemotingService" messageTypes="flex.messaging.messages.RemotingMessage">
-
<default-channels>
-
<channel ref="my-secure-amfphp"/>
-
<channel ref="my-amfphp"/>
-
</default-channels>
-
<destination id="amfphp">
-
<channels>
-
<channel ref="my-secure-amfphp"/>
-
<channel ref="my-amfphp"/>
-
</channels>
-
<properties>
-
<source>*</source>
-
</properties>
-
</destination>
-
</service>
-
</services>
-
<channels>
-
<channel-definition id="my-secure-amfphp" class="mx.messaging.channels.SecureAMFChannel">
-
<endpoint uri="https://{server.name}:{server.port}/amfphp2/gateway.php" class="flex.messaging.endpoints.SecureAMFEndpoint"/>
-
<properties>
-
<add-no-cache-headers>false</add-no-cache-headers>
-
<polling-enabled>false</polling-enabled>
-
<serialization>
-
<instantiate-types>false</instantiate-types>
-
</serialization>
-
</properties>
-
</channel-definition>
-
<channel-definition id="my-amfphp" class="mx.messaging.channels.AMFChannel">
-
<endpoint uri="http://{server.name}:{server.port}/amfphp2/gateway.php" class="flex.messaging.endpoints.AMFEndpoint"/>
-
<properties>
-
<add-no-cache-headers>false</add-no-cache-headers>
-
<polling-enabled>false</polling-enabled>
-
<serialization>
-
<instantiate-types>false</instantiate-types>
-
</serialization>
-
</properties>
-
</channel-definition>
-
</channels>
-
</services-config>
The only problem with this solution is that when on an http page, the swf will try to access crossdomain.xml via https. On Firefox and IE this silently fails. However on Safari (version 3.1.1 as of this writing) this causes the browser to stall indefinitely if you do not have a signed certificate.

Safari will not prompt you to accept the certificate, nor will it silently fail like the other browsers. Since my application is the backend for a CMS, I just went to the homepage via https and accepted the certificate permanently. However, that would not be a good solution for a public application.
June 11th, 2008 at 11:46 pm
Hey, thanks for finding my page! Glad it helped!
October 28th, 2008 at 1:55 pm
really useful thanks : )