There are 2 servers - remote and our (client). Connect to a remote server via CURL (with SSL). There is a client certificate ( .crt and .key ).

Through openSSL with the indication of certificates, the connection goes ( openssl s_client -debug -connect xxx.xxx.xxx.xxx -CAfile cafile.crt -cert cert_file.crt -key key_file.key ) when attempting to access through curl returns null .

In apache, the SSLCertificateFile and SSLCertificateKeyFile parameters SSLCertificateFile SSLCertificateKeyFile with references to the certificate and key in ssl.conf.
Configured virtual host <VirtualHost *:443> in httpd.conf. The result of these manipulations was not given - in any case, null is returned.

How can I set up an ssl connection via curl to a remote server?

Request curl parameters
$ ch = curl_init ();
curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt ($ ch, CURLOPT_SSLCERT, $ cert_path);
curl_setopt ($ ch, CURLOPT_SSLKEY, $ key_path);
curl_setopt ($ ch, CURLOPT_CAINFO, $ CAfile);
curl_setopt ($ ch, CURLOPT_CERTINFO, true);

  • 1. please specify what it is about: curl program or curl library for php program. 2. at the beginning you mention only the certificate and key, and among the arguments of the openssl program, you also use certifikate authority . Do you remember to specify it when calling curl and / or functions in php ? - aleksandr barakin
  • Alexander, 1. Curl library for php 2. Yes, I missed, I’m being corrected - certifikate authority is used, it is correct, specified as the CURLOPT_CAINFO parameter in curl_setopt () Thank you! - J. Doe
  • Give an example of how you specify the parameters before calling the http request. in particular, those related to ssl . You can change the question text by clicking edit below the question text. - aleksandr barakin
  • @alexander barakin $ ch = curl_init (); curl_setopt ($ ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt ($ ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt ($ ch, CURLOPT_SSLCERT, $ cert_path); curl_setopt ($ ch, CURLOPT_SSLKEY, $ key_path); curl_setopt ($ ch, CURLOPT_CAINFO, $ CAfile); curl_setopt ($ ch, CURLOPT_CERTINFO, true); - J. Doe
  • It is better to add this information to the question text itself by clicking the edit button below the question text. - aleksandr barakin

0