@@ -681,19 +681,24 @@ extension ChannelPipeline {
681681 return addHandlers ( [ encoder, decoder, handler] )
682682 }
683683
684- func addSSLHandlerIfNeeded( for key: ConnectionPool . Key , tlsConfiguration: TLSConfiguration ? , handshakePromise: EventLoopPromise < Void > ) {
684+ func addSSLHandlerIfNeeded( for key: ConnectionPool . Key , tlsConfiguration: TLSConfiguration ? , addSSLClient : Bool , handshakePromise: EventLoopPromise < Void > ) {
685685 guard key. scheme == . https else {
686686 handshakePromise. succeed ( ( ) )
687687 return
688688 }
689689
690690 do {
691- let tlsConfiguration = tlsConfiguration ?? TLSConfiguration . forClient ( )
692- let context = try NIOSSLContext ( configuration: tlsConfiguration)
693- let handlers : [ ChannelHandler ] = [
694- try NIOSSLClientHandler ( context: context, serverHostname: key. host. isIPAddress ? nil : key. host) ,
695- TLSEventsHandler ( completionPromise: handshakePromise) ,
696- ]
691+ let handlers : [ ChannelHandler ]
692+ if addSSLClient {
693+ let tlsConfiguration = tlsConfiguration ?? TLSConfiguration . forClient ( )
694+ let context = try NIOSSLContext ( configuration: tlsConfiguration)
695+ handlers = [
696+ try NIOSSLClientHandler ( context: context, serverHostname: key. host. isIPAddress ? nil : key. host) ,
697+ TLSEventsHandler ( completionPromise: handshakePromise)
698+ ]
699+ } else {
700+ handlers = [ TLSEventsHandler ( completionPromise: handshakePromise) ]
701+ }
697702 self . addHandlers ( handlers) . cascadeFailure ( to: handshakePromise)
698703 } catch {
699704 handshakePromise. fail ( error)
0 commit comments