File tree Expand file tree Collapse file tree 5 files changed +24
-0
lines changed Expand file tree Collapse file tree 5 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ fn supported_protocols(
3232 Protocol :: Tlsv10 => SslVersion :: TLS1 ,
3333 Protocol :: Tlsv11 => SslVersion :: TLS1_1 ,
3434 Protocol :: Tlsv12 => SslVersion :: TLS1_2 ,
35+ Protocol :: Tlsv13 => SslVersion :: TLS1_3 ,
3536 }
3637 }
3738
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ static PROTOCOLS: &'static [Protocol] = &[
1919 Protocol :: Tls10 ,
2020 Protocol :: Tls11 ,
2121 Protocol :: Tls12 ,
22+ Protocol :: Tls13 ,
2223] ;
2324
2425fn 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 {
4949 Protocol :: Tlsv10 => SslProtocol :: TLS1 ,
5050 Protocol :: Tlsv11 => SslProtocol :: TLS11 ,
5151 Protocol :: Tlsv12 => SslProtocol :: TLS12 ,
52+ Protocol :: Tlsv13 => SslProtocol :: TLS13 ,
5253 }
5354}
5455
Original file line number Diff line number Diff line change @@ -322,6 +322,8 @@ pub enum Protocol {
322322 Tlsv11 ,
323323 /// The TLS 1.2 protocol.
324324 Tlsv12 ,
325+ /// The TLS 1.3 protocol.
326+ Tlsv13 ,
325327}
326328
327329/// A builder for `TlsConnector`s.
Original file line number Diff line number Diff line change @@ -16,6 +16,25 @@ macro_rules! p {
1616 } ;
1717}
1818
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+
1938#[ test]
2039fn connect_google ( ) {
2140 let builder = p ! ( TlsConnector :: new( ) ) ;
You can’t perform that action at this time.
0 commit comments