@@ -634,19 +634,24 @@ extension ChannelPipeline {
634
634
return addHandlers ( [ encoder, decoder, handler] )
635
635
}
636
636
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 > ) {
638
638
guard key. scheme == . https else {
639
639
handshakePromise. succeed ( ( ) )
640
640
return
641
641
}
642
642
643
643
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
+ }
650
655
self . addHandlers ( handlers) . cascadeFailure ( to: handshakePromise)
651
656
} catch {
652
657
handshakePromise. fail ( error)
0 commit comments