Created
February 12, 2013 02:59
-
-
Save MontealegreLuis/4759907 to your computer and use it in GitHub Desktop.
CURL example with SSL certificate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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