Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sayrer committed Nov 25, 2019
2 parents feb8e40 + 0920f90 commit aa6317d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions rustls-mio/examples/esniclient.rs
Expand Up @@ -15,7 +15,7 @@ use trust_dns_resolver::config::*;
use trust_dns_resolver::Resolver;

fn main() {
let domain = "opaque.website";
let domain = "canbe.esni.defo.ie";
println!("\nContacting {:?} over ESNI\n", domain);

let dns_config = ResolverConfig::cloudflare_https();
Expand All @@ -30,7 +30,7 @@ fn main() {

let dns_name = webpki::DNSNameRef::try_from_ascii_str(domain).unwrap();
let mut sess = rustls::ClientSession::new_with_esni(&Arc::new(config), dns_name, esni_hs);
let mut sock = TcpStream::connect(domain.to_owned() + ":443").unwrap();
let mut sock = TcpStream::connect(domain.to_owned() + ":8443").unwrap();
let mut tls = rustls::Stream::new(&mut sess, &mut sock);
let host_header = format!("Host: {}\r\n", domain);
let mut headers = String::new();
Expand All @@ -56,7 +56,10 @@ fn main() {
println!("read bytes: {}", success);
},
Err(e) => {
stdout().write_all(&plaintext).unwrap();

println!("failure to read the bytes: {:?}", e);

return;
}
}
Expand Down
5 changes: 2 additions & 3 deletions rustls/src/client/hs.rs
Expand Up @@ -237,16 +237,15 @@ fn emit_client_hello_for_retry(sess: &mut ClientSessionImpl,
let esni_ext = ClientExtension::make_esni(handshake.dns_name.as_ref(), esni, ks_bytes, &handshake.randoms);
if let Some(ext) = esni_ext {
exts.push(ext);
//exts.push(ClientExtension::make_sni(handshake.dns_name.as_ref()));
}
// TODO: what if ESNI fails?

// TODO: what if ESNI fails?
}
}

// TODO: what if ESNI is configured but there's no ESNI record?

} else if sess.config.enable_sni {
println!("REGULAR SNI...");
exts.push(ClientExtension::make_sni(handshake.dns_name.as_ref()));
}

Expand Down
2 changes: 1 addition & 1 deletion rustls/src/client/mod.rs
Expand Up @@ -614,7 +614,7 @@ impl ClientSession {
/// encrypt the hostname in the ClientHello.
pub fn new_with_esni(config: &Arc<ClientConfig>, hostname: webpki::DNSNameRef, esni: ESNIHandshakeData) -> ClientSession {
let mut imp = ClientSessionImpl::new(config);
imp.start_handshake(hostname.into(), Some(esni),vec![]);
imp.start_handshake(hostname.into(), Some(esni), vec![]);
ClientSession { imp }
}

Expand Down
2 changes: 1 addition & 1 deletion rustls/src/esni.rs
Expand Up @@ -456,4 +456,4 @@ mod tests {
assert_eq!(expected.len(), encrypted.len());
assert!(crate::msgs::handshake::slice_eq(&expected, encrypted.as_slice()));
}
}
}

0 comments on commit aa6317d

Please sign in to comment.