File tree Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Expand file tree Collapse file tree 1 file changed +8
-5
lines changed Original file line number Diff line number Diff line change @@ -51,14 +51,17 @@ where
51
51
. copied ( )
52
52
. unwrap_or ( 5432 ) ;
53
53
54
- // The value of host is always used as the hostname for TLS validation.
55
- // postgres doesn't support TLS over unix sockets, so the choice for Host::Unix variant here doesn't matter
54
+ // The value of host is used as the hostname for TLS validation,
55
+ // if it's not present, use the value of hostaddr.
56
56
let hostname = match host {
57
- Some ( Host :: Tcp ( host) ) => host. as_str ( ) ,
58
- _ => "" ,
57
+ Some ( Host :: Tcp ( host) ) => host. clone ( ) ,
58
+ // postgres doesn't support TLS over unix sockets, so the choice here doesn't matter Some()
59
+ #[ cfg( unix) ]
60
+ Some ( Host :: Unix ( _) ) => "" . to_string ( ) ,
61
+ None => hostaddr. map_or ( "" . to_string ( ) , |ipaddr| ipaddr. to_string ( ) ) ,
59
62
} ;
60
63
let tls = tls
61
- . make_tls_connect ( hostname)
64
+ . make_tls_connect ( & hostname)
62
65
. map_err ( |e| Error :: tls ( e. into ( ) ) ) ?;
63
66
64
67
// Try to use the value of hostaddr to establish the TCP connection,
You can’t perform that action at this time.
0 commit comments