2011-10-06 10 views
1

PHP에서 자체 서명 된 인증서가있는 안전한 https 서버로 요청해야합니다. 저는 cURL에서 작동하는 명령 행을 가지고 있지만 올바른 PHP 옵션으로 변환하는 데 많은 문제가 있습니다.PHP 로의 cURL 명령 행

실무 컬 명령은 이것이다 :

curl --cacert cert.pem 
    --key cert.key 
    --cert cert.crt 
    --header 'content-type: text/xml' 
    -X POST 
    --data @ftit-request.xml https://serverip/dip/DipWebservice > outputfile 

누군가가 나에게 PHP에서이 올바른 방법을 사용하는 방법에 대한 몇 가지 힌트를 줄 수 있습니까? 작동하지 않는

답변

1

http://php.net/manual/en/book.curl.php

curl_setopt($ch, CURLOPT_VERBOSE, '1'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, '1'); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, '1'); 
curl_setopt($ch, CURLOPT_CAINFO, getcwd().'/cert/ca.crt'); 
curl_setopt($ch, CURLOPT_SSLCERT, getcwd().'/cert/mycert.pem'); 
curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'password'); 
+0

, 난 내가 - 중요한 cert.key를 놓치고 생각? – user982637

+0

php doc에서 기사 읽기. http://www.php.net/manual/ru/function.curl-setopt.php#84374 – TROODON

+0

에서 코드를 보여줍니다. ".pem"파일을 생성하려고합니다. – TROODON