@@ -634,19 +634,24 @@ extension ChannelPipeline {
634634 return addHandlers ( [ encoder, decoder, handler] )
635635 }
636636
637- func addSSLHandlerIfNeeded( for key: ConnectionPool . Key , tlsConfiguration: TLSConfiguration ? , handshakePromise: EventLoopPromise < Void > ) {
637+ func addSSLHandlerIfNeeded( for key: ConnectionPool . Key , tlsConfiguration: TLSConfiguration ? , addSSLClient : Bool , handshakePromise: EventLoopPromise < Void > ) {
638638 guard key. scheme == . https else {
639639 handshakePromise. succeed ( ( ) )
640640 return
641641 }
642642
643643 do {
644- let tlsConfiguration = tlsConfiguration ?? TLSConfiguration . forClient ( )
645- let context = try NIOSSLContext ( configuration: tlsConfiguration)
646- let handlers : [ ChannelHandler ] = [
647- try NIOSSLClientHandler ( context: context, serverHostname: key. host. isIPAddress ? nil : key. host) ,
648- TLSEventsHandler ( completionPromise: handshakePromise) ,
649- ]
644+ let handlers : [ ChannelHandler ]
645+ if addSSLClient {
646+ let tlsConfiguration = tlsConfiguration ?? TLSConfiguration . forClient ( )
647+ let context = try NIOSSLContext ( configuration: tlsConfiguration)
648+ handlers = [
649+ try NIOSSLClientHandler ( context: context, serverHostname: key. host. isIPAddress ? nil : key. host) ,
650+ TLSEventsHandler ( completionPromise: handshakePromise)
651+ ]
652+ } else {
653+ handlers = [ TLSEventsHandler ( completionPromise: handshakePromise) ]
654+ }
650655 self . addHandlers ( handlers) . cascadeFailure ( to: handshakePromise)
651656 } catch {
652657 handshakePromise. fail ( error)
0 commit comments