Статус: Новичок
Группы: Участники
Зарегистрирован: 26.08.2016(UTC) Сообщений: 5 Откуда: spb
|
На дебиан был установлен пакет (linux-amd64_4.0-deb.tgz) программ и симлинком была поменяна ссылка файла libcurl на libcpcurl. код на php заработал Код:
$ch = curl_init();
................
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'CERT_SHA1_HASH_PROP_ID:CERT_SYSTEM_STORE_CURRENT_USER:MY');
curl_setopt($ch, CURLOPT_SSLCERT, 'e80ed2c1ea2fdf04a1fadd2c11f9890a89a77c88');
curl_setopt($ch, CURLOPT_POSTFIELDS, $arPostFields);
................
$strContent = curl_exec($ch);
Пробую повторить тоже самое через curl из пакета в консоле Код:
/opt/cprocsp/bin/amd64/curl --connect-timeout 60 --data "file=@file.txt" --data "param1=aaa" --cert-type CERT_SHA1_HASH_PROP_ID:CERT_SYSTEM_STORE_CURRENT_USER:MY --cert "e80ed2c1ea2fdf04a1fadd2c11f9890a89a77c88" --trace - --verbose --request POST --url "https://site......" -o result_curl.txt
И получаю ошибку 58 : Problem with the local SSL certificate Почему проблема с локальным сертификатом? если php скрипт с curl команда выполняется от одного и того же пользователя? в curl есть возможно залогировать вызов libcurl, (--libcurl filename.log) получаю Код:/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, "https://site......");
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "file=@file.txt¶m1=aaa");
curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)-1);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3 SSPI/CPRO Feb 29 2016 23:40:09 zlib/1.2.8 libidn/1.29");
curl_easy_setopt(hnd, CURLOPT_SSLCERTTYPE, "CERT_SHA1_HASH_PROP_ID:CERT_SYSTEM_STORE_CURRENT_USER:MY");
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50);
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT, 60);
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1);
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself.
CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_HTTPHEADER set to a objectpointer
CURLOPT_SSLCERT set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_DEBUGFUNCTION set to a functionpointer
CURLOPT_DEBUGDATA set to a objectpointer
CURLOPT_SOCKOPTFUNCTION set to a functionpointer
CURLOPT_SOCKOPTDATA set to a objectpointer
*/
return (int)ret;
}
/**** End of sample code ****/
Если тоже самое сделать, но использовать не "/opt/cprocsp/bin/amd64/curl" а "curl" то вывод будет таким Код:
/********* Sample code generated by the curl command line tool **********
* All curl_easy_setopt() options are documented at:
* http://curl.haxx.se/libcurl/c/curl_easy_setopt.html
************************************************************************/
#include <curl/curl.h>
int main(int argc, char *argv[])
{
CURLcode ret;
CURL *hnd;
struct curl_slist *slist1;
slist1 = NULL;
slist1 = curl_slist_append(slist1, "Content-Type: multipart/form-data");
hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_URL, "https://site......");
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "file=@file.txt¶m1=aaa");
curl_easy_setopt(hnd, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)99);
curl_easy_setopt(hnd, CURLOPT_USERAGENT, "curl/7.38.0");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, slist1);
curl_easy_setopt(hnd, CURLOPT_MAXREDIRS, 50L);
curl_easy_setopt(hnd, CURLOPT_SSLCERT, "e80ed2c1ea2fdf04a1fadd2c11f9890a89a77c88");
curl_easy_setopt(hnd, CURLOPT_SSLCERTTYPE, "CERT_SHA1_HASH_PROP_ID:CERT_SYSTEM_STORE_CURRENT_USER:MY");
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_CONNECTTIMEOUT_MS, 60000L);
curl_easy_setopt(hnd, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(hnd, CURLOPT_TCP_KEEPALIVE, 1L);
/* Here is a list of options the curl code used that cannot get generated
as source easily. You may select to either not use them or implement
them yourself.
CURLOPT_WRITEDATA set to a objectpointer
CURLOPT_WRITEFUNCTION set to a functionpointer
CURLOPT_READDATA set to a objectpointer
CURLOPT_READFUNCTION set to a functionpointer
CURLOPT_SEEKDATA set to a objectpointer
CURLOPT_SEEKFUNCTION set to a functionpointer
CURLOPT_ERRORBUFFER set to a objectpointer
CURLOPT_STDERR set to a objectpointer
CURLOPT_DEBUGFUNCTION set to a functionpointer
CURLOPT_DEBUGDATA set to a objectpointer
CURLOPT_HEADERFUNCTION set to a functionpointer
CURLOPT_HEADERDATA set to a objectpointer
*/
ret = curl_easy_perform(hnd);
curl_easy_cleanup(hnd);
hnd = NULL;
curl_slist_free_all(slist1);
slist1 = NULL;
return (int)ret;
}
/**** End of sample code ****/
Почему при использовании "/opt/cprocsp/bin/amd64/curl" в запрос не попала запись CURLOPT_SSLCERT? Цитата:curl_easy_setopt(hnd, CURLOPT_SSLCERT, "e80ed2c1ea2fdf04a1fadd2c11f9890a89a77c88"); или сертификат как то по другому надо указывать? Отредактировано пользователем 26 августа 2016 г. 16:00:55(UTC)
| Причина: Не указана
|