title: Shopify PHP with SSL certificate: where do I set USE_SSL_PEM?
body: <p>First steps with Shopify here...</p>
  
  <p>I'm running PHP 5.4 and apache 2.2 on a windows 7 machine with cURL 7.24. I am trying to follow along with this Sample App (https://github.com/cmcdonaldca/ohShopify-Sample-App) which uses the ohShopify PHP adapter but...</p>
  
  <p>I'm getting the "SSL certificate problem, verify that the CA cert is OK" error after I allow the app access to the shop (which is on <a href="https://xxxxxx.myshopify.com" rel="nofollow">https://xxxxxx.myshopify.com</a>). This problem is mentioned in the PHP API FAQ - Q2 (<a href="http://wiki.shopify.com/PHP_API_FAQ" rel="nofollow">http://wiki.shopify.com/PHP_API_FAQ</a>) with a possible solution. But I don't understand where to "set USE_SSL_PEM to true in your configuration". What configuration does this mean? PHP.ini ? CURLOPT_ ? Just define it in the php code? I've tried it in the php code in the config_lib.php file that is part of the Sample App like so: </p>
  
  <pre><code>define('USE_SSL_PEM',true);
  </code></pre>
  
  <p>but that doesn't work.. and a search through the Sample App files reveals that nothing uses it... so I've got to be in the wrong place.</p>
  
  <p>The second part in the FAQ is to define 'CA_FILE' in the .php code. I'm okay with that, I think, as I have exported the myshopify.com certificate and it seems valid. I converted it from .cer to .pem using: </p>
  
  <pre><code>openssl x509 -inform DES -in ie_shopify.cer -out shopify.pem -text
  </code></pre>
  
  <p>And then in the config_lib.php file:</p>
  
  <pre><code>define('CA_FILE', getcwd() . '\\shopify.pem');
  </code></pre>
  
  <p>I have confirmed that CA_FILE does point correctly to the file with an absolute path.</p>
  
  <p>I've also tried what is suggested here (http://unitstep.net/blog/2009/05/05/using-curl-in-php-to-access-https-ssltls-protected-sites/) by setting CURLOPT_CAINFO in the ohShopify curlSetopts() function that is being called but with the same result.</p>
  
  <p>And (as mentioned) I found out how to convert .cer to .pem from here (http://curl.haxx.se/docs/sslcerts.html)</p>
  
  <p>Thanks,</p>
  
  <p>Neil</p>
  
  <p>UPDATE: solved! Instead of trusting the .pem file that I had first extracted using Internet Explorer as a .cer file and then coverted to a .pem file using openssl, I went to:</p>
  
  <pre><code>curl.haxx.se/docs/caextract.html 
  </code></pre>
  
  <p>...and grabbed the Mozilla CA certificate bundle - this is already in .pem format. I placed the cacert.pem file in the same directory as my other one and updated the CURLOPT_CAINFO line in the curlSetopts() function (I added this line previously in shopify.php). As before, I pointed directly at the file:</p>
  
  <pre><code>curl_setopt($ch, CURLOPT_CAINFO, 'D:/apache/htdocs/cacert.pem');
  </code></pre>
  
  <p>And it works. Moving on.</p>
  
  <p>UPDATE 2: just to clarify, since I originally looked for the solution in the PHP API FAQ for Shopify (mentioned above) ... I did not need to set the USE_SSL_PEM value (wherever it belongs) or to add the define CA_FILE code. The advice about CURLOPT_CAINFO from the unitstep.net blog was correct.</p>