@@ -30,12 +30,13 @@ impl<S: Read+Write+Send> StreamWrapper<S> for SslStream<S> {
3030}
3131
3232pub trait NegotiateSsl {
33- fn negotiate_ssl < S > ( & mut self , stream : S ) -> Result < Box < StreamWrapper < S > > , Box < Error > >
33+ fn negotiate_ssl < S > ( & mut self , host : & str , stream : S )
34+ -> Result < Box < StreamWrapper < S > > , Box < Error > >
3435 where S : Read +Write +Send +' static ;
3536}
3637
3738impl NegotiateSsl for SslContext {
38- fn negotiate_ssl < S > ( & mut self , stream : S ) -> Result < Box < StreamWrapper < S > > , Box < Error > >
39+ fn negotiate_ssl < S > ( & mut self , _ : & str , stream : S ) -> Result < Box < StreamWrapper < S > > , Box < Error > >
3940 where S : Read +Write +Send +' static {
4041 let stream = try!( SslStream :: new ( self , stream) ) ;
4142 Ok ( Box :: new ( stream) )
@@ -55,7 +56,7 @@ pub enum SslMode<N = NoSsl> {
5556pub enum NoSsl { }
5657
5758impl NegotiateSsl for NoSsl {
58- fn negotiate_ssl < S : Read +Write > ( & mut self , stream : S )
59+ fn negotiate_ssl < S : Read +Write > ( & mut self , _ : & str , _ : S )
5960 -> Result < Box < StreamWrapper < S > > , Box < Error > > {
6061 match * self { }
6162 }
@@ -142,7 +143,14 @@ pub fn initialize_stream<N>(params: &ConnectParams, ssl: &mut SslMode<N>)
142143 }
143144 }
144145
145- match negotiator. negotiate_ssl ( socket) {
146+ // Postgres doesn't support SSL over unix sockets
147+ let host = match params. target {
148+ ConnectTarget :: Tcp ( ref host) => host,
149+ #[ cfg( feature = "unix_socket" ) ]
150+ ConnectTarget :: Unix ( _) => return Err ( ConnectError :: BadResponse )
151+ } ;
152+
153+ match negotiator. negotiate_ssl ( host, socket) {
146154 Ok ( stream) => Ok ( stream) ,
147155 Err ( err) => Err ( ConnectError :: SslError ( err) )
148156 }
0 commit comments