mirror of
https://github.com/YGGverse/agate.git
synced 2026-04-08 12:35:28 +00:00
add test for TLS version selection
Since rustls does not even support TLS versions below 1.2, no need to check for that.
This commit is contained in:
parent
8b4692b08b
commit
8a6eb65b48
3 changed files with 24 additions and 0 deletions
|
|
@ -254,3 +254,25 @@ fn serve_secret() {
|
|||
|
||||
assert_eq!(page.header.status, Status::Success);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "AlertReceived(ProtocolVersion)")]
|
||||
fn explicit_tls_version() {
|
||||
use rustls::{ClientSession, ProtocolVersion};
|
||||
use std::io::Read;
|
||||
use std::net::TcpStream;
|
||||
|
||||
let _server = Server::new(&["--addr", "[::]:1976", "-3"]);
|
||||
|
||||
let mut config = rustls::ClientConfig::new();
|
||||
// try to connect using only TLS 1.2
|
||||
config.versions = vec![ProtocolVersion::TLSv1_2];
|
||||
|
||||
let dns_name = webpki::DNSNameRef::try_from_ascii_str("localhost").unwrap();
|
||||
let mut session = ClientSession::new(&std::sync::Arc::new(config), dns_name);
|
||||
let mut tcp = TcpStream::connect(addr(1976)).unwrap();
|
||||
let mut tls = rustls::Stream::new(&mut session, &mut tcp);
|
||||
|
||||
let mut buf = [0; 10];
|
||||
tls.read(&mut buf).unwrap();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue