How can I check if php curl was compiled with ssl and has support for ssl? I mean, a simple check to see if curl is available would be:
if(extension_loaded('curl'))
but how do I check if curl also has support for ssl? I need this check because ssl support is needed to using oauth2 - based API and I need some way to quickly check if client's php is able to the oauth2 before actually using it (and failing)
Curl has built-in support for Secure Transport connections (its more secure version is called TLS). When you make a Curl request for an HTTPS URL, Curl automatically checks the target URL's SSL certificate against the local CA certificate store and warns if it is invalid, self-signed, or has expired.
cURL by default will ensure each SSL connection to be secure by verifying the server's SSL certificate. You'll get SSL error when running cURL against https -based websites with SSL certificates that are either misconfigured, expired, or self-signed.
If libcurl was built with Schannel (Microsoft's native TLS engine) or Secure Transport (Apple's native TLS engine) support, then libcurl will still perform peer certificate verification, but instead of using a CA cert bundle, it will use the certificates that are built into the OS.
With the curl command line tool: --cacert [file] Add the CA cert for your server to the existing default CA certificate store. The default CA certificate store can be changed at compile time with the following configure options: --with-ca-bundle=FILE: use the specified file as CA certificate store.
AFAIK cURL doesn't have a way to check if SSL is enabled or disabled, testing it and catching would let you know for sure.
You could try testing this, to see if it works. (I don't have a server without SSL to test on..)
<?php
$v = curl_version();
print $v['ssl_version']; // I get: OpenSSL/0.9.8 - I presume you won't if it is not enabled
?>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With