Skip to content

Instantly share code, notes, and snippets.

@MontealegreLuis
Created February 12, 2013 02:59
Show Gist options
  • Save MontealegreLuis/4759907 to your computer and use it in GitHub Desktop.
Save MontealegreLuis/4759907 to your computer and use it in GitHub Desktop.
CURL example with SSL certificate
<?php
$url = 'https://www.somedomain.com/a-page';
$certificateFile = 'ceritificate.pem';
$certificatePassword = 'password';
$handler = curl_init();
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_SSL_VERIFYHOST => false, //You may need to change this to true
CURLOPT_SSL_VERIFYPEER => false, //You may need to change this to true
CURLOPT_URL => $url ,
CURLOPT_SSLCERT => $certificateFile,
CURLOPT_SSLCERTPASSWD => $certificatePassword,
);
curl_setopt_array($handler , $options);
$output = curl_exec($handler);
if(!$output) {
echo "Curl Error : " . curl_error($handler);
} else {
// Do something with output
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment