@@ -681,19 +681,24 @@ extension ChannelPipeline {
681
681
return addHandlers ( [ encoder, decoder, handler] )
682
682
}
683
683
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 > ) {
685
685
guard key. scheme == . https else {
686
686
handshakePromise. succeed ( ( ) )
687
687
return
688
688
}
689
689
690
690
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
+ }
697
702
self . addHandlers ( handlers) . cascadeFailure ( to: handshakePromise)
698
703
} catch {
699
704
handshakePromise. fail ( error)
0 commit comments