Parse, PHP, and cURL on Windows Azure
I was recently trying to use Parse’s PHP SDK and was running into some issues when I deployed the project to Azure. Whenever I would attempt to run any of the Parse scripts I would get a 500 Internal Server Error
.
It turns out that Parse is using cURL
which does not ship with it’s own CA certificate bundle. To fix the problem I needed to specify a CA cert bundle for PHP’s cURL. All the steps below can be accomplished in the Kudu interface which you can access at [your-azure-site-name].scm.azurewebsites.net
.
1. Create Custom php.ini
- In the Kudu console, click on the planet-looking icon.
- From there go in the config folder, and then in the PHP-5.5.18 folder (or whatever version you’re using).
- Run
copy php.ini d:\home\site
to copy it to your site folder. - Click the Home icon, and then go in the site folder to find your copy of php.ini.
- Edit the file. Add the following line:
curl.cainfo ="D:\home\site\ca-bundle.crt"
2. Create applicationhost.xdt
- While still at
D:\home\site\
create a new file.echo temp > applicationhost.xdt
- Edit the file and paste in the following contents: ``` <?xml version=”1.0”?>
- Make sure to change the php version if needed.
**3. Create ca-bundle.crt**
- While still at `D:\home\site\` create a new file.
echo temp > ca-bundle.crt ```
- Edit the file and paste the contents of
ca-bundle.crt
found here:
http://curl.haxx.se/docs/caextract.html
4. Restart the site
References
- https://github.com/projectkudu/kudu/wiki/Xdt-transform-samples#using-a-custom-phpini
- http://blogs.msdn.com/b/azureossds/archive/2015/06/12/verify-peer-certificate-from-php-curl-for-azure-apps.aspx
- http://ea.tl/2012/02/02/windows-php-curl-ssl-certificate-problem.html
Load Comments