卷曲返回“未知协议". [英] Curl returns "Unknown protocol"

查看:93
本文介绍了卷曲返回“未知协议".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

即使Google上有很多结果,但似乎都没有给出答案.我有一个Debian盒子,在这里我可以这样做:

Even though there's a lot of results on Google none of them seem to give an answer. I have a Debian box where I do this:

# curl https://localhost/api/v1/status --verbose
* About to connect() to localhost port 443 (#0)
*   Trying ::1...
* connected
* Connected to localhost (::1) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
* Closing connection #0
curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

我无法通过未知协议.我已经尝试过-ssl -sslv3,但是他们却无济于事.实际上,-sslv3给我的结果略有不同:

I can't get passed the unknown protocol thing. I've tried -ssl -sslv3 but they get me nowhere. Actually, -sslv3 gets me slightly different results:

s# curl https://localhost/api/v1/status --verbose -sslv3
* About to connect() to localhost port 443 (#0)
*   Trying ::1...
* connected
* Connected to localhost (::1) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: none
  CApath: /etc/ssl/certs
* SSLv3, TLS handshake, Client hello (1):
* SSLv3, TLS alert, Server hello (2):
* error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number
* Closing connection #0

我的虚拟主机配置为(片段):

My virtualhost is configured as thus (fragment):

    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM

    SSLCertificateFile    /etc/apache2/ssl.key/xxx/ssl.cert
    SSLCertificateKeyFile /etc/apache2/ssl.key/xxx/xxx.xxx.key

    #   Server Certificate Chain:
    SSLCertificateChainFile /etc/apache2/ssl.key/sub.class1.server.ca.pem

    #   Certificate Authority (CA):
    SSLCACertificateFile /etc/apache2/ssl.key/ca.pem

    <FilesMatch "\.(cgi|shtml|phtml|php)$">
            SSLOptions +StdEnvVars
    </FilesMatch>
    <Directory /usr/lib/cgi-bin>
            SSLOptions +StdEnvVars
    </Directory>
    BrowserMatch "MSIE [2-6]" \
            nokeepalive ssl-unclean-shutdown \
            downgrade-1.0 force-response-1.0
    # MSIE 7 and newer should be able to use keepalive
    BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

任何帮助将不胜感激.

修改:更新 我想我发现了自己的问题!

edit: Update I think I found my own problem!

虚拟主机已绑定到外部接口,并且curl尝试通过localhost连接.因此,它永远不会在配置的虚拟主机上结束.

The Virtual Host was bound to the external interface, and curl was trying to connect over localhost. So it never ended up at the configured virtual host.

要解决此问题,我创建了一个绑定到127.0.0.1:80的新VirtualHost条目,该条目仅允许来自本地主机的连接.就我的目的而言,就足够了.

To fix this, I have created a new VirtualHost entry bound to 127.0.0.1:80 that only allows connections from localhost. For my purposes, that is enough.

推荐答案

尽管不是OP的情况,但是当您不小心尝试使用HTTPS调用HTTP服务器时,通常在本地时,会出现cURL中的错误未知协议"发展.
只需提及一下,以防有人谷歌发现此错误并落入此处.

Although it is not the case of the OP, the error "Unknown protocol" in cURL appears when you accidentally trying to call HTTP server using HTTPS, usually during local development.
Just mentioning it in case someone Googles this error and lands here.

curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

curl: (35) error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

这篇关于卷曲返回“未知协议".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆