function connect_ssl() { writeTimeFile("HTTP_client:sono dentro connect_ssl"); $url = $this->protocol . $this->host . ":" . $this->port; writeTimeFile("HTTP_client: URL" . $url); $post = "POST " . $this->path . " HTTP/1.1\r\n" . "Host: " . $this->host . ":" . $this->port . "\r\n" . "Accept: text/html, text/xml, image/gif, image/jpeg, *; q=.2, */*; q=.2\r\n" . "Content-Type: text/xml; charset=UTF-8; action=\"" . $this->action . "\"\r\n" . "Cache-Control: no-cache\r\n" . "Connection: Close\r\n" . "Content-Length: {$this->dataLength} \r\n" . "Pragma: no-cache\r\n" . "SOAPAction: \"\"\r\n" . "User-Agent: myAgent\r\n" . "\r\n" . $this->post_data; //writeTimeFile("HTTP_client: POST" . $post); set_time_limit(2000); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $post); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_SSLCERTTYPE, "PEM"); curl_setopt($ch, CURLOPT_SSLCERT, './certificates/athon1.ihe-europe.org.pem'); // curl_setopt($ch, CURLOPT_SSLCERTPASSWD, 'PASSWORD'); curl_setopt($ch, CURLOPT_SSLKEYTYPE, "PEM"); curl_setopt($ch, CURLOPT_SSLKEY, './certificates/athon1.ihe-europe.org.key'); // curl_setopt($ch, CURLOPT_SSLKEYPASSWD, 'PASSWORD'); curl_setopt($ch, CURLOPT_CAINFO, './certificates/cacerts.pem'); // curl_setopt($ch,CURLOPT_CAPATH,MY_CAPATH); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, TRUE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); if (curl_errno($ch)) { makeErrorFromRegistry("XDSRegistryNotAvailable", "Unable to connect to the Registry to register document"); writeTimeFile("HTTP_client: Errori di curl" . curl_errno($ch) . " " . curl_error($ch)); } curl_close($ch); return $result; }
$client->set_path($reg_path); $client->set_idfile($idfile); $client->set_save_files($save_files); $client->set_action("urn:ihe:iti:2007:RegisterDocumentSet-b"); $client->set_tmp_path($tmp_path); #### SETTAGGI DEL TLS ######## INOLTRO AL REGISTRY E ATTENDO LA RISPOSTA ########## writeTimeFile($idfile . "--Repository: Inoltro al registry e attendo la risposta"); $registry_response_arr = $client->send_request(); #$headers_da_registry = apache_request_headers(); //writeTimeFile($idfile."--Repository:".$registry_response_arr[0]."aaa".$registry_response_arr[1]); $registry_response_log = $registry_response_arr[1]; writeTimeFile($idfile . "--Repository: Ho ottenuto la risposta dal registry"); #### CASO DI ERORE DI CERTIFICATO if ($registry_response_log != "") { makeErrorFromRegistry("XDSRegistryError", $registry_response_log); } //END OF if($registry_response_log!="") #### SONO FUORI DAL CASO DI ERRORE $registry_response = $registry_response_arr[0]; if ($save_files) { #### N.B. NELLA RISPOSTA DAL REGISTRY HO HEADERS + BODY ## 5- scrivo in locale la RISPOSTA DAL REGISTRY writeTmpFiles($registry_response, $idfile . "-da_registry-" . $idfile); //============= END OF FORWARDING AL REGISTRY del NIST ===============// } // Se la risposta del registry è errata cancello il documento creato nel repository if (strpos(strtoupper($registry_response), "ERROR") || strpos(strtoupper($registry_response), "FAILURE")) { if ($windows > 0) { exec('del ' . $document_URI2 . ' /q'); } else {
$client->set_post_data($post_data); writeTimeFile($idfile . "--Repository: La dimensione è " . filesize($file_forwarded_written)); $client->set_data_length(filesize($file_forwarded_written)); $client->set_path($reg_path); $client->set_idfile($idfile); $client->set_save_files($save_files); $client->set_tmp_path($tmp_path); ######## INOLTRO AL REGISTRY E ATTENDO LA RISPOSTA ########## writeTimeFile($idfile . "--Repository: Inoltro al registry e attendo la risposta"); $registry_response_arr = $client->send_request(); #$headers_da_registry = apache_request_headers(); $registry_response_log = $registry_response_arr[1]; writeTimeFile($idfile . "--Repository: Ho ottenuto la risposta dal registry"); #### CASO DI ERORE DI CERTIFICATO if ($registry_response_log != "") { makeErrorFromRegistry($registry_response_log); } //END OF if($registry_response_log!="") ############################################################# #### SONO FUORI DAL CASO DI ERRORE $registry_response = $registry_response_arr[0]; if ($save_files) { #### N.B. NELLA RISPOSTA DAL REGISTRY HO HEADERS + BODY ## 5- scrivo in locale la RISPOSTA DAL REGISTRY writeTmpFiles($registry_response, $idfile . "-da_registry-" . $idfile); //============= END OF FORWARDING AL REGISTRY del NIST ===============// } // Se la risposta del registry è errata cancello il documento creato nel repository if (strpos(strtoupper($registry_response), "ERROR") || strpos(strtoupper($registry_response), "FAILURE")) { if ($windows > 0) { exec('del ' . $document_URI2 . ' /q');