简体   繁体   English

CURL错误:140770FC:SSL例程:SSL23_GET_SERVER_HELLO:未知协议

[英]CURL error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

I'm trying to use proxy and SSL certificate with CURL , But I get errors. 我正在尝试通过CURL使用代理和SSL证书,但出现错误。

Here is the CURL code: 这是CURL代码:

//Website
$url = 'https://www.stubhub.com';

//Curl
$curl=curl_init();

//SSL
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, true );
curl_setopt( $curl, CURLOPT_SSL_VERIFYHOST, 2 );
curl_setopt( $curl, CURLOPT_CAINFO, 'C:\xampp\cacert.pem' );

curl_setopt( $curl, CURLOPT_URL,trim( $url ) );
curl_setopt($curl, CURLOPT_REFERER, $url);
curl_setopt( $curl, CURLOPT_AUTOREFERER, true );
curl_setopt( $curl, CURLOPT_FOLLOWLOCATION, true );
curl_setopt( $curl, CURLOPT_FAILONERROR, true );
curl_setopt( $curl, CURLOPT_HEADER, false );
curl_setopt( $curl, CURLINFO_HEADER_OUT, false );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
curl_setopt( $curl, CURLOPT_BINARYTRANSFER, true );
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 0 );
curl_setopt( $curl, CURLOPT_TIMEOUT, 0 );
curl_setopt( $curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36' );

//Proxy
curl_setopt($curl, CURLOPT_HTTPPROXYTUNNEL, 1);
curl_setopt($curl, CURLOPT_PROXY, '177.190.147.241:41545');
curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
curl_setopt ($curl, CURLOPT_PORT , 80);

curl_setopt($curl, CURLOPT_COOKIEFILE,__DIR__."/cookie.txt");
curl_setopt( $curl, CURLOPT_MAXREDIRS, 10 );
curl_setopt( $curl, CURLOPT_ENCODING, '' );

curl_setopt( $curl, CURLOPT_VERBOSE, true );
curl_setopt( $curl, CURLOPT_NOPROGRESS, true );
curl_setopt( $curl, CURLOPT_STDERR, $vbh );

I get the following response: 我得到以下回应:

* Rebuilt URL to: https://www.stubhub.com/
*   Trying 177.190.147.241...
* TCP_NODELAY set
* Connected to 177.190.147.241 (177.190.147.241) port 41545 (#0)
* Establish HTTP proxy tunnel to www.stubhub.com:80
> CONNECT www.stubhub.com:80 HTTP/1.1
Host: www.stubhub.com:80
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/22.0.1207.1 Safari/537.1
Proxy-Connection: Keep-Alive

< HTTP/1.1 200 OK
< 
* Proxy replied OK to CONNECT request
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:\xampp\cacert.pem
  CApath: none
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Curl_http_done: called premature == 1
* Closing connection 0
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

How to fix this? 如何解决这个问题?

* Rebuilt URL to: https://www.stubhub.com/

You are trying to reach the URL https://www.stubhub.com/ - which means the given host on port 443 (default for https) with protocol https (ie HTTP over TLS). 您正在尝试访问URL https://www.stubhub.com/这意味着端口443(协议默认为https)上的给定主机具有协议https(即TLS上的HTTP)。

But, for unknown reasons you explicitly specify that port 80 should be used instead of port 443: 但是,出于未知原因,您明确指定应使用端口80而不是端口443:

curl_setopt ($curl, CURLOPT_PORT , 80);

This means it will not connect to the host on port 443 but on port 80: 这意味着它将不在端口443上连接到主机,而在端口80上:

* Establish HTTP proxy tunnel to www.stubhub.com:80
> CONNECT www.stubhub.com:80 HTTP/1.1

Port 80 is for plain HTTP. 端口80用于纯HTTP。 Nevertheless the client will try https (HTTP over TLS) since this is what the URL said. 不过,客户端将尝试使用https(基于TLS的HTTP),因为这就是URL所说的。 The client will thus try to initiate a TLS handshake by sending the ClientHello. 因此,客户端将尝试通过发送ClientHello来发起TLS握手。 Since the server expects a plain HTTP request but gets a TLS ClientHello instead it will reply with the HTTP error response. 由于服务器期望一个普通的HTTP请求,但是获得一个TLS ClientHello,因此它将以HTTP错误响应进行回复。 The client then will try to parse this response as the expected TLS response and fail: 然后,客户端将尝试将此响应解析为预期的TLS响应并失败:

error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

How to fix this? 如何解决这个问题?

Don't set CURLOPT_PORT to 80. Just don't set CURLOPT_PORT so that it is taken from the URL. 不要将CURLOPT_PORT设置为80。只是不要将CURLOPT_PORT设置为从URL中获取。 From the documentation : 文档中

This option sets number to be the remote port number to connect to, instead of the one specified in the URL or the default port for the used protocol. 此选项将number设置为要连接的远程端口号, 而不是URL或所用协议的默认端口中指定的端口号。 Usually, you just let the URL decide which port to use but this allows the application to override that. 通常,您只需让URL决定使用哪个端口,但这可以使应用程序覆盖它。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Curl 错误:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure111 - Curl error: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure111 OpenSSL 错误消息:错误:1407742E:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 警报协议版本 - OpenSSL Error messages: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version php cURL错误:错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败 - Php cURL error:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure cURL 错误 (35):错误:14077458:SSL 例程:SSL23_GET_SERVER_HELLO:tlsv1 无法识别的名称 - cURL Error (35): error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 unrecognized name PHP Curl:SSL例程:SSL23_GET_SERVER_HELLO:reason(1112) - PHP Curl: SSL routines:SSL23_GET_SERVER_HELLO:reason(1112) 错误:错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败 - Error:error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure MAMP SSL错误:“错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败” - MAMP SSL error: “error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure” php-paypal-error:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败 - php-paypal-error: 14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure 部落API冲突| 错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败 - Clash Of Clan API | error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure PayPal IPN OPENSSL错误:14077410:SSL例程:SSL23_GET_SERVER_HELLO:sslv3警报握手失败 - PayPal IPN OPENSSL error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM