How to detect if a server is using SPDY

江枫思渺然 提交于 2020-01-22 11:18:44

问题


Any way to detect if a remote website supports SPDY and what version it is?

Something I can use from the command line like a bash script.

Tried sending custom User-Agent headers with curl but can't get any kind of response headers that would help me.

The idea is to be able to get SPDY:true/false Version:3.1/3.0... for any domain.


回答1:


openssl s_client -connect google.com:443 -nextprotoneg ''
CONNECTED(00000003)
Protocols advertised by server: spdy/3.1, spdy/3, http/1.1



回答2:


The SPDY protocol negotiation happens during the initial TLS handshake.

There are currently two ways to negotiate the protocol: the older one is called NPN (http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04). In the ClientHello TLS message the client sends the NPN extension with ID 0x3374. The server replies with a ServerHello TLS message that also contains the list of protocols supported by the server also in a NPN extension. The client then chooses the protocol and sends its choice, encrypted, to the server.

The newer method has been designed for HTTP 2.0 and is called ALPN (http://tools.ietf.org/html/draft-ietf-tls-applayerprotoneg-05). The ClientHello TLS message contains the ALPN extension with ID 0x10. The client, this time, sends the list of protocols supported and the server replies with a ServerHello TLS message that contains the protocol chosen by the server, also in a ALPN extension.

In both the NPN and ALPN extension the list of protocols is sent as strings such as http/1.1 or spdy/3.

Once the protocol has been chosen, the TLS handshake continues and then both parties will start to speak immediately the protocol that they have chosen.

The only way to be aware of negotiation of the protocol is therefore to use TLS and to have a client that exposes the protocol negotiation extensions. Each client does that in a specific way, but there is not yet support for bash scripts, as far as I know.

HAProxy for example has support for both NPN and ALPN (http://cbonte.github.io/haproxy-dconv/configuration-1.5.html) and Jetty 9.2 too has support for both NPN and ALPN (both for clients and servers).

Other servers like Nginx or Apache have support for NPN with patches for ALPN (since it will be needed by HTTP 2.0 anyway).

NPN will eventually fade away; Google's Adam Langley has stated that NPN will be deprecated in favour of ALPN.



来源:https://stackoverflow.com/questions/23742928/how-to-detect-if-a-server-is-using-spdy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!