title: PHP: ftp_login fails with "failed to create the SSL context"
body: <p>I'm trying to upload a file to a remote FTP server (which requires FTPES) using PHP. The script I've written works locally, but on the live server ftp_login() returns false and the following warnings appear in the error log:</p>
  
  <pre><code>PHP Warning:  ftp_login(): failed to create the SSL context [...]
  PHP Warning:  ftp_login(): AUTH command ok; starting SSL connection. [...]
  </code></pre>
  
  <p>I know that the login details are correct (since identical code works locally). I can successfully connect to the FTP server from the live server using curl on the command line.</p>
  
  <p>The server is running PHP 5.3.3 (Zend Server on CentOS). I can see from phpinfo that the PHP configure command includes -with-openssl=/usr/local/openssl-0.9.8o</p>
  
  <p>The code is simply this:</p>
  
  <pre><code>$ftpConnection = ftp_ssl_connect('hostname');
  if (!$ftpConnection) {
      echo "Failed to connect to FTP Site\n";
      return false;
  }
  if (!ftp_login($ftpConnection, 'xxxxx', 'xxxxx')) {
      echo "Failed to login to FTP site\n";
      return false;
  }
  </code></pre>
  
  <p>For reference my local box (where this works fine) is running PHP 5.3.3-1ubuntu9.3.</p>
  
  <p>Can anyone point me in the right direction?</p>
  
  <p><strong>Edit</strong>: I've noticed that the SSL certificate for this server isn't actually valid as the hostname I'm connecting to does not match the common name on the cert. Is there a PHP setting somewhere which controls how strict it or openSSL is regarding certificate errors? That might be the only issue.</p>