使用SSL连接到使用PHP的EPP服务器

时间:2012-01-23 15:16:21

标签: php ssl

我即将连接到安全的EPP服务器并发送XML请求,然后再次以XML格式接收响应。

我需要在PHP中执行此操作。所以我需要使用SSL证书通过TCP连接到特定端口上的EPP服务器(因为这是我到目前为止的信息,仍在等待我的IP列入白名单并向我发送证书)。

所以我的问题可能看起来有些愚蠢,但我是否需要使用fsockopencURL进行连接,如何定义我需要使用SSL以及如何定义和使用此问题SSL证书以及那个?

3 个答案:

答案 0 :(得分:2)

好吧,你只需初始化curl,设置选项和exec curl请求:

$url="your_url";
$handle = curl_init(); 
curl_setopt($handle, CURLOPT_URL,$url); 
curl_setopt($handle, CURLOPT_SSLCERT, $sslcertpath); //$sslcertpath - path to your certificate file
curl_setopt($oCurl, CURLOPT_SSL_VERIFYPEER, true); //may want to set false for debugging
//[...]
$response = curl_exec($handle);
curl_close($handle);

var_dump($response);

您可以在手册中找到完整的卷曲选项列表: curl_setopt manual

答案 1 :(得分:0)

这样卷曲
CURLOPT_CAINFO=>YOUR_CAINFO_PATH,
CURLOPT_SSLCERT=>YOUR_CERT_PATH,
CURLOPT_SSLCERTPASSWD=>YOUR_CERT_PWD_IF_NECESSARY,
CURLOPT_FOLLOWLOCATION=>1,
CURLOPT_TIMEOUT=>YOUR_HTTPS_TIMEOUT,

应该做的伎俩

答案 2 :(得分:-1)

<?php
$epp_server = 'ote-console.centralnic.com'; $port = 700; $verify_peer = 0;
//$epp_server = 'epp.ispapi.net'; $port = 1700; $verify_peer = 0;
//$epp_server = 'epp.test.norid.no'; $port = 700; $verify_peer = 0;
//$epp_server = 'epp-test.rotld.ro'; $port = 5555; $verify_peer = 0; // SSLv3
$opts = array(
    'ssl' => array(
    'verify_peer' => $verify_peer,
    'cafile' => "/CAfiles/gd_bundle.crt",
    'local_cert' => "/certs/certificate.cer",
    'passphrase' => 'YourCertificatePasswordHere'
    )
);

$context = stream_context_create($opts);

// TLSv1

$fp = stream_socket_client( "tls://$epp_server:$port", $errno, $errstr, 1, STREAM_CLIENT_CONNECT, $context);

// SSLv3
//$fp = stream_socket_client( "sslv3://$epp_server:$port", $errno, $errstr, 1, STREAM_CLIENT_CONNECT, $context);

if (!$fp) {
    echo "$errstr ($errno)<br />\n";
}

else {
    fwrite($fp, "GET / HTTP/1.0\r\nHost: www.example.com\r\nAccept: */*\r\n\r\n");
    while (!feof($fp)) {
        echo fgets($fp, 1024);
    }

    fclose($fp);

}

?>