Curly-Q(uestion)s

Or , how I’ve spent the better part of the last several days, because I get obsessed with some computer that won’t obey me. Why can’t I simply treat it like my wife or my dog or my kids, and just let it dominate me? I suppose it’s a disorder of some kind. But if I medicated it, I’d never get anything done.

Helpful Links (great guys)

Cheap Work Around

Snippet

CURLOPT_SSL_VERIFYPEER => true

(Why do it the easy way when you can spend 20 hours and not get sneered at by random guys on the internet? )

Php Code (some of it):

Snippet

public static function curlPost($url , $header , $jsondata )
    {
        $json_string = json_encode($jsondata, JSON_PRETTY_PRINT);
        print ($json_string);
        fwrite(STDOUT, $json_string . "\n");
 
        $curl = curl_init();
 
        $myArray = _web::curl_options_array($url , "POST" , $header , null);
        curl_setopt_array($curl,  $myArray );
        curl_setopt($curl , CURLOPT_STDERR, fopen('/curl.txt', 'w+'));
 
        curl_setopt($curl, CURLOPT_POSTFIELDS, $jsondata);
 
 
        $response = curl_exec($curl);
        $err     = curl_errno( $curl );
        $errmsg  = curl_error( $curl );
        fwrite(STDOUT, $err . " " . $errmsg . "\n");
        $outheader  = curl_getinfo( $curl );
        fwrite(STDOUT, $outheader . "\n");
 
        curl_close($curl);
        var_dump($response);
        var_dump($err);
        var_dump($errmsg);
        var_dump($outheader);
 
        return $response;
 
    }
    public static function curl_options_array($url , $method = null , $header = null , $json = null)
    {
        if ( is_null ($method )) $method = "GET";
    //    CURLOPT_SSL_VERIFYPEER => false,


        $retArray =  array(
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 0,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_VERBOSE => true ,
        CURLOPT_ENCODING => "" ,                  // handle all encodings
        CURLOPT_CONNECTTIMEOUT => 120 ,           // timeout on connect
        CURLOPT_TIMEOUT => 120 ,                  // timeout on response
        CURLOPT_CUSTOMREQUEST => $method
        );

        if (  !empty($header)  ) $retArray[] = array(CURLOPT_HTTPHEADER => $header); // append the header
        if (  !empty($json) & $method == "POST" )   $retArray[] = array(CURLOPT_POSTFIELDS => $json); // append the data

        return $retArray;
    }


PHP.INI
With the php.ini fragment below, this produces an error code 77 error setting certificate verify locations:  CAfile: C:\Program Files\PHP\v8.0.3\extras\ssl\cacert.perm CApath: none  

And I've been trying various settings, even trying to integrate with Windows as below, so the current ini file doesn't reflect all the permutations it's gone through.

; https://martinsblog.dk/windows-iis-with-php-curl-60-ssl-certificate-problem-unable-to-get-local-issuer-certificate/
curl.cainfo = C:\Program Files\PHP\v8.0.3\extras\ssl\cacert.perm
openssl.cafile= C:\Program Files\PHP\v8.0.3\extras\ssl\cacert.perm
; https://thegeekpage.com/how-to-view-digital-certificates-installed-in-windows-10/
openssl.capath= C:\Users\tharvey2.UTK\AppData\Roaming\Microsoft\SystemCertificates\My\Certificates

Web Project

One thing I also tried was creating a Devsense/php web project , used IIS Express, and clicked the Enable SSL checkbox, with similar results: 60 SSL certificate problem: unable to get local issuer certificate

php.ini

curl.cainfo =”C:\Program Files (x86)\PHP\v8.0\extras\ssl\cacert.pem”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: