Warning: Cannot use a scalar value as an array in /home/admin/public_html/forum/include/fm.class.php on line 757

Warning: Invalid argument supplied for foreach() in /home/admin/public_html/forum/include/fm.class.php on line 770
Форумы портала PHP.SU :: Версия для печати :: CURL + SSL
Форумы портала PHP.SU » » Работа с сетью » CURL + SSL

Страниц (1): [1]
 

1. snikers987 - 06 Июня, 2013 - 19:36:11 - перейти к сообщению
Приветствую.

Столкнулся с такой задачей:
Есть некий сервис на который нужно послать защищенный POST запрос, все мои попытки его выполнить не увенчались успехом.

Показываю как пробовал:

PHP:
скопировать код в буфер обмена
  1.  
  2. <?PHP
  3.  
  4. $body = 'some content';
  5.  
  6. // initializing cURL with the API URL:
  7. $ch = curl_init("https://service.com/order.wsdl");
  8. // setting the request type to POST:
  9. curl_setopt($ch, CURLOPT_POST, 1);
  10. // setting the content type:
  11. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
  12. // setting the authorization method to BASIC:
  13. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  14. // supplying your credentials:
  15. curl_setopt($ch, CURLOPT_USERPWD, "Login:Password");
  16. // filling the request body with your SOAP message:
  17. curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
  18.  
  19. // configuring cURL not to verify the server certificate:
  20. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  21.  
  22.  // setting the path where cURL can find the client certificate:
  23. curl_setopt($ch, CURLOPT_SSLCERT, "ca.pem");
  24. // setting the path where cURL can find the client certificate’s
  25. // private key:
  26. curl_setopt($ch, CURLOPT_SSLKEY, "ca.key");
  27. // setting the key password:
  28. curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "qwertyqwerty");
  29.  
  30.  
  31. curl_setopt($ch, CURLOPT_HEADER, 1);
  32. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  33. echo $result = curl_exec($ch);
  34. echo curl_error($ch);
  35. // closing cURL:
  36.  



Запрос отваливается с ошибкой: SSL read: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca, errno 0

Если можно объясните как добиться успеха, имено в этих строках затык

PHP:
скопировать код в буфер обмена
  1.  
  2.  // setting the path where cURL can find the client certificate:
  3. curl_setopt($ch, CURLOPT_SSLCERT, "ca.pem");
  4. // setting the path where cURL can find the client certificate’s
  5. // private key:
  6. curl_setopt($ch, CURLOPT_SSLKEY, "ca.key");
  7. // setting the key password:
  8. curl_setopt($ch, CURLOPT_SSLKEYPASSWD, "qwertyqwerty");
  9.  


Нужно ли как-то дополнительно конфигурировать веб-сервер?

Файлы *.key и *.pem(переименовал из *.crt) я генерировал в CPanel, правильно ли это?

На сервере у клиента сPanel, shell доступ тоже есть, буду весьма благодарен.
2. snikers987 - 16 Июля, 2013 - 19:48:12 - перейти к сообщению
Все оказалось прозаично, детальное изучение мануалов и игнорирование утверждений заказчика решило проблему.

 

Powered by ExBB FM 1.0 RC1