Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if curl has support for ssl?

Tags:

php

curl

ssl

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)

like image 918
Dmitri Avatar asked Apr 24 '11 21:04

Dmitri


People also ask

How does curl detect SSL certificates?

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.

Why do I get SSL error when running curl against HTTPS?

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.

Does libcurl support TLS certificate verification?

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.

How do I add a CA certificate to a curl file?

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.


Video Answer


1 Answers

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
?>
like image 163
Ben Periton Avatar answered Sep 28 '22 04:09

Ben Periton