File tree 5 files changed +24
-0
lines changed
5 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ fn supported_protocols(
32
32
Protocol :: Tlsv10 => SslVersion :: TLS1 ,
33
33
Protocol :: Tlsv11 => SslVersion :: TLS1_1 ,
34
34
Protocol :: Tlsv12 => SslVersion :: TLS1_2 ,
35
+ Protocol :: Tlsv13 => SslVersion :: TLS1_3 ,
35
36
}
36
37
}
37
38
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ static PROTOCOLS: &'static [Protocol] = &[
19
19
Protocol :: Tls10 ,
20
20
Protocol :: Tls11 ,
21
21
Protocol :: Tls12 ,
22
+ Protocol :: Tls13 ,
22
23
] ;
23
24
24
25
fn convert_protocols ( min : Option < :: Protocol > , max : Option < :: Protocol > ) -> & ' static [ Protocol ] {
Original file line number Diff line number Diff line change @@ -49,6 +49,7 @@ fn convert_protocol(protocol: Protocol) -> SslProtocol {
49
49
Protocol :: Tlsv10 => SslProtocol :: TLS1 ,
50
50
Protocol :: Tlsv11 => SslProtocol :: TLS11 ,
51
51
Protocol :: Tlsv12 => SslProtocol :: TLS12 ,
52
+ Protocol :: Tlsv13 => SslProtocol :: TLS13 ,
52
53
}
53
54
}
54
55
Original file line number Diff line number Diff line change @@ -322,6 +322,8 @@ pub enum Protocol {
322
322
Tlsv11 ,
323
323
/// The TLS 1.2 protocol.
324
324
Tlsv12 ,
325
+ /// The TLS 1.3 protocol.
326
+ Tlsv13 ,
325
327
}
326
328
327
329
/// A builder for `TlsConnector`s.
Original file line number Diff line number Diff line change @@ -16,6 +16,25 @@ macro_rules! p {
16
16
} ;
17
17
}
18
18
19
+ #[ test]
20
+ fn connect_google_tls13 ( ) {
21
+ let builder = p ! (
22
+ TlsConnector :: builder( )
23
+ . min_protocol_version( Some ( Protocol :: Tlsv13 ) )
24
+ . max_protocol_version( Some ( Protocol :: Tlsv13 ) )
25
+ . build( ) ) ;
26
+ let s = p ! ( TcpStream :: connect( "google.com:443" ) ) ;
27
+ let mut socket = p ! ( builder. connect( "google.com" , s) ) ;
28
+
29
+ p ! ( socket. write_all( b"GET / HTTP/1.0\r \n \r \n " ) ) ;
30
+ let mut result = vec ! [ ] ;
31
+ p ! ( socket. read_to_end( & mut result) ) ;
32
+
33
+ println ! ( "{}" , String :: from_utf8_lossy( & result) ) ;
34
+ assert ! ( result. starts_with( b"HTTP/1.0" ) ) ;
35
+ assert ! ( result. ends_with( b"</HTML>\r \n " ) || result. ends_with( b"</html>" ) ) ;
36
+ }
37
+
19
38
#[ test]
20
39
fn connect_google ( ) {
21
40
let builder = p ! ( TlsConnector :: new( ) ) ;
You can’t perform that action at this time.
0 commit comments