Connect to EPP Server with PHP, using SSL

后端 未结 3 1307
醉酒成梦
醉酒成梦 2021-01-14 00:13

I\'m about to connect to a secure EPP server and send an XML request and then receive a response in XML format again.

I need to do this in PHP. So I need to connect

相关标签:
3条回答
  • curl with something like

    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,
    

    should do the trick

    0 讨论(0)
  • 2021-01-14 00:33
    <?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);
    
    }
    
    ?>
    
    0 讨论(0)
  • 2021-01-14 00:34

    Well, you just init curl, set options and exec curl request:

    $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);
    

    You can find a complete list of curl options in the manual: curl_setopt manual

    0 讨论(0)
提交回复
热议问题