2015-02-01 2 views
0

SSL의 작동 방식을 스스로 가르치려고합니다. 나는 나머지를 통해 두 개의 서버를 연결하고 cURL을 통해 https를 연결해야합니다. 나는 crt와 열쇠 selfsigned ok를 얻는다, 브라우저는 평소에 묻는다. .. 세계를 인쇄하는 것은 ssl apache 엔진이 작동하고있는 것을 보여준다. .. 그러나 컬이 아니다. .. 여기의 코드는있다 (나는 시험해보고있는 놀고있다. 데비안의 가상 상자에서) 데비안 dev에 서버에 말림 :cURL에서 제목과 호스트 이름이 일치하지 않습니다. SSL

0* About to connect() to local.domain.net port 443 (#0) 
* Trying 192.168.1.110... 
* connected 
* Connected to local.domain.net (192.168.1.110) port 443 (#0) 
* successfully set certificate verify locations: 
* CAfile: none 
    CApath: /etc/ssl/certs 
* SSL connection using ECDHE-RSA-AES256-GCM-SHA384 
* Server certificate: 
*  subject: CN=internal-server 
*  start date: 2014-11-09 21:40:16 GMT 
*  expire date: 2024-11-06 21:40:16 GMT 
*** SSL: certificate subject name 'internal-server' does not match target host name 'local.domain.net'** 
* Closing connection #0 

에 SSL 인증서 및 키이 작성된 : 내가 명령 줄에 위의 PHP를 실행하면

$url = 'https://local.domain.net/curl.php'; 

     // OK cool - then let's create a new cURL resource handle 
     $ch = curl_init($url); 

     curl_setopt($ch, CURLOPT_VERBOSE, 1); 

     // Set a referer 
     //curl_setopt($ch, CURLOPT_REFERER, "http://www.internal-server.co.uk"); 

     // User agent 
     curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/1.0"); 

     // Timeout in seconds 
     //curl_setopt($ch, CURLOPT_TIMEOUT, 10); 

     //don't verify the signiture 
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 

     // Include header in result? (0 = yes, 1 = no) 
     //curl_setopt($ch, CURLOPT_HEADER, 0); 

     // Should cURL return or print out the data? (true = return, false = print) 
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

     //set the basic auth to any then set the creds 
     curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
     $username = self::$http_username; 
     $password = self::$http_password; 
     curl_setopt($ch, CURLOPT_USERPWD, "$username:$password"); 

     $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code 

     // Download the given URL, and return output 
     $output = curl_exec($ch); 

     // Close the cURL resource, and free system resources 
     curl_close($ch); 

     print_r($output); 

     echo ' 


'; 

난 다음 얻을 dev 서버를 통해 :

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout apache.key -out apache.crt 

인증서를 생성하고 키를 잘 만들었습니다. 브라우저를 통해 연결할 때 평소와 같이 '정말입니까?'라는 메시지가 나타났습니다. 그러나 어떤 이유로 php를 통해 커서를 가져 오지 못했습니다 ..

설정할 수 있습니까? openSSL을 사용하여 수동으로 인증서를 보내시겠습니까?

답변

0

인증서 주체 이름 '내부 서버'대상 호스트 이름 'local.domain.net'

SSL 인증서가 특정 도메인에 바인딩과 일치하지 않습니다. OpenSSL로 인증서를 만드는 동안 도메인 이름 (local.domain.net)을 입력하라는 메시지가 표시되어야합니다.

브라우저는 자체 서명 인증서를 사용했기 때문에뿐만 아니라 도메인과 일치하지 않기 때문에 경고를 표시합니다. 이 경고에는 여러 가지 이유가있을 수 있습니다.

관련 문제