Skip to content
Snippets Groups Projects

Verify if curl is using TLS

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    The snippet can be accessed without any authentication.
    Authored by Raul Barreras
    Edited
    curl-version.php 508 B
    <?php
    // based on https://stackoverflow.com/questions/27904854/verify-if-curl-is-using-tls
    if (php_sapi_name() == "cli") {
    
            $ch = curl_init('https://www.howsmyssl.com/a/check');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
            $data = curl_exec($ch);
            curl_close($ch);
    
            $json = json_decode($data);
            echo $json->tls_version;
    
    } else {
            $url = 'https://'.$_SERVER['HTTP_HOST'];
            header('Location: https://'.$_SERVER['HTTP_HOST']);
            die();
    }
    ?>
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Please register or to comment