2016-09-27 3 views
1

내 Pem 파일은이 형식입니다.컬 오류 : 개인 키 파일을 설정할 수 없습니다. 'test.pem'type PEM

Bag Attributes 
localKeyID: 
friendlyName: test 
subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise 
issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/[email protected] 
-----BEGIN CERTIFICATE----- 

-----END CERTIFICATE----- 

Bag Attributes 
localKeyID: 
friendlyName: test 
subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise 
issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/[email protected] 
-----BEGIN CERTIFICATE----- 

-----END CERTIFICATE----- 

Bag Attributes 
localKeyID: 
friendlyName: test 
subject=/C=GB/ST=London/L=Soho/O=Rightmove/OU=RTDF/CN=cmexpertise 
issuer=/C=GB/ST=London/L=Soho/O=Rightmove/OU=Operations/CN=RTDF Test Issuing CA v3/[email protected] 
-----BEGIN RSA PRIVATE KEY----- 
Proc-Type: 4,ENCRYPTED 
DEK-Info: DES-EDE3-CBC,B9E036426B7AEDA6 
-----END RSA PRIVATE KEY----- 

저는이 PHP 코드를 사용하고 있습니다. 이 오류가 발생합니다.

Curl Error: unable to set private key file: 'test.pem' type PEM

코드. https://www.sslshopper.com/certificate-decoder.html 및 인증서는이 사이트에 유효합니다

$json_data // it's a json array. 

    $url = "https://adfapi.adftest.rightmove.com/v1/property/sendpropertydetails"; 
    $ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL, $url); 

    // $pemFile = tmpfile(); 
    // fwrite($pemFile, "test.pem"); //the path for the pem file 
    // $tempPemPath = stream_get_meta_data($pemFile); 
    // $tempPemPath = $tempPemPath['uri']; 

    curl_setopt($ch, CURLOPT_SSLCERT, "test.pem"); 
    curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM"); 
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/javascript')); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, True); 
    curl_setopt($ch, CURLOPT_POST, True); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data); 
    curl_setopt($ch, CURLOPT_VERBOSE, true); 

    $result = curl_exec($ch); 

    if(!$result) 
    { 
     echo "Curl Error: " . curl_error($ch); 
    } 
    else 
    { 
     echo "Success: ". $result; 
    } 

    $info = curl_getinfo($ch); 

    curl_close($ch); // close cURL handler 

    if (empty($info['http_code'])) { 
      die("No HTTP code was returned"); 
    } else { 
     // load the HTTP codes 
     $http_codes = parse_ini_file("path/to/the/ini/file/I/pasted/above"); 

     // echo results 
     echo "The server responded: <br />"; 
     echo $info['http_code'] . " " . $http_codes[$info['http_code']]; 
    } 

나는 인증서 디코더 온라인 확인.

그래서 여기서 나는 문제를 이해할 수 없다. 나는 또한 ssl 명령을 시도했다.

+1

컬 오류 : 0200107B : 시스템 라이브러리 : fopen을 : 알 수없는 오류 (찾을 수 없습니다 키, 잘못된 암호 구문 또는 잘못된 파일 PEM 클라이언트 인증서, OpenSSL이 오류 오류를로드 할 수 없습니다 형식?).이 PHP 코드 및 pem 파일을 사용할 때 오류가 발생했습니다. 해당 파일의 개인 키가 인증서의 해당 공개 키와 일치하지 않기 때문입니다. – Veeram

+0

@ Reddy. 답장 형에게 감사드립니다. 거기에 두 가지 오류가 하나의 오류는 pem 파일의 pem 파일에 오류가 있었고 다른 오류는 내가 코드에 CURLOPT_SSLCERTPASSWD()를 포함하지 않았다는 것입니다. – Bhavin

답변

0

두 가지 오류가 있습니다.

  • 하나의 오류가 pem 파일이었습니다. pem 파일 생성에 오류가있었습니다.
  • 다른 오류는 코드에 CURLOPT_SSLCERTPASSWD()가 포함되지 않았기 때문입니다.

코드,

curl_setopt($ch,CURLOPT_SSLCERTTYPE,"PEM"); 
    curl_setopt($ch, CURLOPT_SSLCERT, "test.pem"); 
    curl_setopt($ch, CURLOPT_SSLCERTPASSWD, '******'); // password 
관련 문제