@@ -901,10 +901,9 @@ fn protocol_order(p: native_tls::Protocol) -> u8 {
901901 native_tls:: Protocol :: Tlsv10 => 2 ,
902902 native_tls:: Protocol :: Tlsv11 => 3 ,
903903 native_tls:: Protocol :: Tlsv12 => 4 ,
904- // TLS 1.3 is supported as a format string for future compatibility, but native-tls
905- // only ships Tlsv12 as the maximum, so we rank it after Tlsv12 for validation purposes.
906- // The non-exhaustive enum means we need a catch-all; future variants will get a
907- // higher rank automatically.
904+ // TLS 1.3 is reserved for future compatibility at the protocol-mapping layer, so we
905+ // rank it after Tlsv12 for validation purposes. The non-exhaustive enum means we need
906+ // a catch-all; unmatched and future variants receive the same fallback rank as TLS 1.3.
908907 _ => 5 ,
909908 }
910909}
@@ -914,14 +913,19 @@ fn protocol_order(p: native_tls::Protocol) -> u8 {
914913/// Supported formats: "TLSv1.0", "TLSv1.1", "TLSv1.2", "TLS1.0", "TLS1.1", "TLS1.2"
915914/// (case-insensitive, with or without the 'v' in "TLS"). Returns an error for unrecognized
916915/// or unsupported values.
916+ ///
917+ /// Note: TLS 1.3 (`"TLSv1.3"` / `"TLS1.3"`) is reserved for future support by this connector
918+ /// build and is rejected through the protocol-mapping layer.
917919fn string_to_protocol ( s : & str ) -> Result < native_tls:: Protocol , String > {
918920 let normalized = s. to_uppercase ( ) ;
919921 // Accept both documented forms: "TLSV1.2" and "TLS1.2"
920922 match normalized. as_str ( ) {
921923 "TLSV1.0" | "TLS1.0" => Ok ( native_tls:: Protocol :: Tlsv10 ) ,
922924 "TLSV1.1" | "TLS1.1" => Ok ( native_tls:: Protocol :: Tlsv11 ) ,
923925 "TLSV1.2" | "TLS1.2" => Ok ( native_tls:: Protocol :: Tlsv12 ) ,
924- "TLSV1.3" | "TLS1.3" => Err ( "TLS 1.3 is not yet supported by the native-tls library" . to_string ( ) ) ,
926+ "TLSV1.3" | "TLS1.3" => {
927+ Err ( "TLS 1.3 is not supported by this connector build" . to_string ( ) )
928+ }
925929 _ => Err ( format ! (
926930 "Unsupported TLS version: '{}'. Supported versions are: TLSv1.0, TLSv1.1, TLSv1.2" ,
927931 s
@@ -1083,6 +1087,12 @@ mod tests {
10831087 use crate :: tests:: test_api:: postgres:: CONN_STR ;
10841088 use url:: Url ;
10851089
1090+ #[ test]
1091+ fn rejects_tls13_with_neutral_error_message ( ) {
1092+ let err = string_to_protocol ( "TLS1.3" ) . unwrap_err ( ) ;
1093+ assert_eq ! ( err, "TLS 1.3 is not supported by this connector build" ) ;
1094+ }
1095+
10861096 #[ tokio:: test]
10871097 async fn test_custom_search_path_pg ( ) {
10881098 async fn test_path ( schema_name : & str ) -> Option < String > {
0 commit comments