卷曲错误:无法连接到<url>端口8444:连接被拒绝,在本地但不在服务器中工作

时间:2017-11-29 10:43:49

标签: php ssl curl port cpanel

我正在尝试整合银行在线支付系统。为此,我需要与银行服务器进行握手。使用crt和密钥文件我已经在curhost的localhost中完成了它,在执行握手时将crt和密钥文件发送到带服务器并且他们批准了它。但是当我在服务器上传项目时不知何故它给出错误“卷曲错误:无法连接到端口:连接被拒绝” ,我想知道可能导致此问题的原因,我是否需要将crt和密钥文件存储在特定文件夹中?该网站已通过ssl认证。 我的卷曲代码是:

$request = <has xml file>
    $twpg_gateway_url = <url>;
    $twpg_cert_file = getcwd().'\wp-content\themes\nikkon\website.com.crt';
    //echo getcwd();exit();
    $twpg_key_file = getcwd().'\wp-content\themes\nikkon\website.key';
    $twpg_key_password = <password>;
    $curl = curl_init();

    $options = array(
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HEADER => false,
        CURLOPT_FOLLOWLOCATION => true,
        CURLOPT_SSL_VERIFYHOST => false,
        CURLOPT_SSL_VERIFYPEER => false,
        CURLOPT_POST => true,
        CURLOPT_USERAGENT => 'Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)',
        CURLOPT_VERBOSE        => true,
        CURLOPT_URL => $twpg_gateway_url . '/Exec',
        CURLOPT_POSTFIELDS => $request,
        CURLOPT_HTTPHEADER => array('Content-Type: text/xml'),
        CURLOPT_TIMEOUT => 30
    );

    if ($twpg_cert_file != '') {
        $options[CURLOPT_SSLCERT] = $twpg_cert_file;
        $options[CURLOPT_SSLKEY] = $twpg_key_file;
        $options[CURLOPT_SSLKEYPASSWD] = $twpg_key_password;
    }

    curl_setopt_array($curl, $options);

    $response = curl_exec($curl);
    if(!$response)
    {
        echo "Curl Error : " . curl_error($curl);
    }
    curl_close($curl);

    return $response;

1 个答案:

答案 0 :(得分:0)

这是我用来测试端口是否打开的脚本。

try {
    $hostname = isset($_SERVER['argv'][1])? $_SERVER['argv'][1]: 'localhost';
    $port = isset($_SERVER['argv'][2])? $_SERVER['argv'][2]: 80;

    printf(' ? Attempting to connect to: %s:%u', $hostname, $port);

    if(@fsockopen($hostname, $port, $code, $message, 5) === false) {
        throw new RuntimeException($message, $code);
    }

    printf("\r:) Successfully connected to: %s:%u", $hostname, $port);
}
catch(Exception $e) {
    printf("\nError: %u - %s", $e->getCode(), $e->getMessage());
    exit(1);
}

从命令行php socket-test.php example.com 25运行它。 或者您可以将其修改为在Web浏览器中工作。