[Solved] Rustls can not connect to some sites

#1

I decided to immigrate to rustls, but when I tried to run its example, I encountered that cannot have a successful handshake with some sites.
I think it’s related to protocol support, but I don’t have any idea how I can fix it.

sh-3.2$ target/release/examples/client https://google.com/
Status:
301 Moved Permanently
Headers:
{
    "location": "https://www.google.com/",
    "content-type": "text/html; charset=UTF-8",
    "date": "Sat, 09 Mar 2019 09:48:45 GMT",
    "expires": "Mon, 08 Apr 2019 09:48:45 GMT",
    "cache-control": "public, max-age=2592000",
    "server": "gws",
    "content-length": "220",
    "x-xss-protection": "1; mode=block",
    "x-frame-options": "SAMEORIGIN",
    "alt-svc": "quic=\":443\"; ma=2592000; v=\"46,44,43,39\""
}
Body:
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>

.

sh-3.2$ target/release/examples/client https://aibtv.com/
FAILED: an error occurred trying to connect: received fatal alert: HandshakeFailure

.

sh-3.2$ curl -I https://aibtv.com/
HTTP/1.1 200 OK
Date: Sat, 09 Mar 2019 14:00:01 GMT
Server: Apache
Last-Modified: Fri, 01 Mar 2019 19:37:44 GMT
Accept-Ranges: bytes
Content-Length: 21314
Content-Type: text/html
0 Likes

#2

I found the answer.
https://docs.rs/rustls/0.15.1/src/rustls/suites.rs.html#373-385

pub static ALL_CIPHERSUITES: [&'static SupportedCipherSuite; 9] =
    [// TLS1.3 suites
     &TLS13_CHACHA20_POLY1305_SHA256,
     &TLS13_AES_256_GCM_SHA384,
     &TLS13_AES_128_GCM_SHA256,

     // TLS1.2 suites
     &TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
     &TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
     &TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
     &TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
     &TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
     &TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256];

Many sites cannot support one of these CipherSuites, I think it’s too early for using rustls as a client.

0 Likes