Search code examples
iossslcertificatetitanium

Titanium - "The certificate for this server is invalid. You might be connecting to a server that is pretending to be DOMAIN.COM”


I am developing an app for iOS using Titanium Appcelerator. I am struggling with securing the connections to my server. I bought a UCC certificate to protect my server (and other websites) and installed it. When I go on any browser, it displays that the connection is secured.

Now, when I try to create a connection from the app to my server, I get the following error:

The certificate for this server is invalid. You might be connecting to a server that is pretending to be DOMAIN.COM

I've tried with other secured domains, and it works fine. I am using Ti.Network.createHTTPClient to create my connections. Does anyone have any idea about that problem? Is there something I'm missing here?


Solution

  • I found the reason why in my case the connection was refused. The catch was that I hadn't concatenated the two cert files given by godaddy, which doesn't seem to be a problem on browser, but was breaking the chain of trust for the app. Correcting that part fixed the issue, using:

    cat gd_bundle-g1-g2.crt >> my_server.crt
    

    to create the full crt file.

    Note: The first cert file is downloadable on Godaddy's website, but is also attached when you download your crt file.