Last active
August 14, 2019 12:03
-
-
Save jbg/2b24ec191dac2bd0ad165d43efd50b11 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
ct-logs = "0.6.0" | |
http = "0.1.18" | |
hyper = "0.12.33" | |
hyper-rustls = "0.17.0" | |
rustls = "0.16.0" | |
tokio = "0.1.22" | |
webpki-roots = "0.17.0" | |
*/ | |
let client = { | |
let mut roots = RootCertStore::empty(); | |
roots.add_server_trust_anchors(&TLS_SERVER_ROOTS); | |
let mut cert = &config::TRUSTED_TLS_CERT.as_bytes()[..]; | |
roots.add_pem_file(&mut cert).unwrap(); | |
let mut config = ClientConfig::new(); | |
config.enable_early_data = true; | |
config.root_store = roots; | |
config.session_persistence = ClientSessionMemoryCache::new(128); | |
config.ct_logs = Some(&ct_logs::LOGS); | |
config.alpn_protocols.push("http1".as_bytes().to_vec()); | |
config.alpn_protocols.push("h2".as_bytes().to_vec()); | |
let mut http = HttpConnector::new(4); | |
http.enforce_http(false); | |
let https = HttpsConnector::from((http, config)); | |
Client::builder() | |
.max_idle_per_host(config::HTTPS_CLIENT_MAX_IDLE_PER_HOST) | |
.build(https) | |
}; | |
let uri = "https://www.googleapis.com/..."; | |
let payload = hashmap! { "..." => "..." }; | |
let req = Request::builder() | |
.method("POST") | |
.uri(uri) | |
.header("Content-Type", "application/x-www-form-urlencoded") | |
.header("Accept", "application/json") | |
.body(serde_urlencoded::to_string(payload)?.into())?; | |
let fut = client.request(req); | |
let timeout_fut = Timeout::new(fut, Duration::from_secs(config::HTTPS_CLIENT_REQUEST_TIMEOUT)); | |
timeout_fut.compat().await?; | |
/* | |
[2019-08-14T11:55:59Z DEBUG hyper::client::connect::dns] resolving host="www.googleapis.com" | |
[2019-08-14T11:55:59Z DEBUG hyper::client::connect::http] connecting to [2a00:1450:4009:81a::200a]:443 | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor] adding I/O source: 4194305 | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Write for: 1 | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Write for: 1 | |
[2019-08-14T11:56:00Z DEBUG hyper::client::connect::http] connecting to 216.58.198.170:443 | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor] adding I/O source: 8388610 | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Write for: 2 | |
[2019-08-14T11:56:00Z DEBUG hyper::client::connect::http] connected to Some(V6([2a00:1450:4009:81a::200a]:443)) | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor] dropping I/O source: 2 | |
[2019-08-14T11:56:00Z DEBUG rustls::client::hs] No cached session for DNSNameRef("www.googleapis.com") | |
[2019-08-14T11:56:00Z DEBUG rustls::client::hs] Not resuming any session | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Read for: 1 | |
[2019-08-14T11:56:00Z DEBUG rustls::client::hs] Using ciphersuite TLS13_CHACHA20_POLY1305_SHA256 | |
[2019-08-14T11:56:00Z DEBUG rustls::client::tls13] Not resuming | |
[2019-08-14T11:56:00Z DEBUG rustls::client::tls13] TLS1.3 encrypted extensions: [Protocols([PayloadU8([104, 50])])] | |
[2019-08-14T11:56:00Z DEBUG rustls::client::hs] ALPN protocol is Some([104, 50]) | |
[2019-08-14T11:56:00Z DEBUG rustls::client::tls13] Server cert is [... snip ...] | |
[2019-08-14T11:56:00Z DEBUG rustls::verify] Valid SCT signed by Google on Google 'Pilot' log | |
[2019-08-14T11:56:00Z DEBUG rustls::verify] Valid SCT signed by Sectigo on Sectigo 'Mammoth' CT log | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Read for: 1 | |
[2019-08-14T11:56:00Z DEBUG h2::client] binding client connection | |
[2019-08-14T11:56:00Z DEBUG h2::client] client connection bound | |
[2019-08-14T11:56:00Z DEBUG h2::codec::framed_write] send; frame=Settings { flags: (0x0), enable_push: 0 } | |
[2019-08-14T11:56:00Z DEBUG hyper::client::pool] pooling idle connection for "https://www.googleapis.com" | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Read for: 1 | |
[2019-08-14T11:56:00Z DEBUG rustls::session] Sending warning alert CloseNotify | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor::registration] scheduling Read for: 1 | |
[2019-08-14T11:56:00Z DEBUG tokio_reactor] dropping I/O source: 1 | |
[2019-08-14T11:56:00Z DEBUG hyper::client] client connection error: connection error: broken pipe | |
[2019-08-14T11:56:00Z ERROR crate::https] unhandled: Error(Canceled, "connection closed") | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment