@@ -48,12 +48,12 @@ internal TcpConnectionFactory(ProxyServer server)
48
48
49
49
internal string GetConnectionCacheKey ( string remoteHostName , int remotePort ,
50
50
bool isHttps , List < SslApplicationProtocol > applicationProtocols ,
51
- ProxyServer proxyServer , IPEndPoint upStreamEndPoint , ExternalProxy externalProxy )
51
+ IPEndPoint upStreamEndPoint , ExternalProxy externalProxy )
52
52
{
53
- //http version is ignored since its an application level decision b/w HTTP 1.0/1.1
54
- //also when doing connect request MS Edge browser sends http 1.0 but uses 1.1 after server sends 1.1 its response.
55
- //That can create cache miss for same server connection unnecessarily especially when prefetching with Connect.
56
- //http version 2 is separated using applicationProtocols below.
53
+ // http version is ignored since its an application level decision b/w HTTP 1.0/1.1
54
+ // also when doing connect request MS Edge browser sends http 1.0 but uses 1.1 after server sends 1.1 its response.
55
+ // That can create cache miss for same server connection unnecessarily especially when prefetching with Connect.
56
+ // http version 2 is separated using applicationProtocols below.
57
57
var cacheKeyBuilder = new StringBuilder ( $ "{ remoteHostName } -{ remotePort } -" +
58
58
//when creating Tcp client isConnect won't matter
59
59
$ "{ isHttps } -") ;
@@ -103,17 +103,19 @@ internal async Task<string> GetConnectionCacheKey(ProxyServer server, SessionEve
103
103
session . HttpClient . Request . RequestUri . Host ,
104
104
session . HttpClient . Request . RequestUri . Port ,
105
105
isHttps , applicationProtocols ,
106
- server , session . HttpClient . UpStreamEndPoint ?? server . UpStreamEndPoint ,
106
+ session . HttpClient . UpStreamEndPoint ?? server . UpStreamEndPoint ,
107
107
customUpStreamProxy ?? ( isHttps ? server . UpStreamHttpsProxy : server . UpStreamHttpProxy ) ) ;
108
108
}
109
109
110
110
111
111
/// <summary>
112
112
/// Create a server connection.
113
113
/// </summary>
114
+ /// <param name="server">The proxy server.</param>
114
115
/// <param name="session">The session event arguments.</param>
115
116
/// <param name="isConnect">Is this a CONNECT request.</param>
116
117
/// <param name="applicationProtocol"></param>
118
+ /// <param name="noCache">if set to <c>true</c> [no cache].</param>
117
119
/// <param name="cancellationToken">The cancellation token for this async task.</param>
118
120
/// <returns></returns>
119
121
internal Task < TcpServerConnection > GetServerConnection ( ProxyServer server , SessionEventArgsBase session , bool isConnect ,
@@ -131,9 +133,11 @@ internal Task<TcpServerConnection> GetServerConnection(ProxyServer server, Sessi
131
133
/// <summary>
132
134
/// Create a server connection.
133
135
/// </summary>
136
+ /// <param name="server">The proxy server.</param>
134
137
/// <param name="session">The session event arguments.</param>
135
138
/// <param name="isConnect">Is this a CONNECT request.</param>
136
139
/// <param name="applicationProtocols"></param>
140
+ /// <param name="noCache">if set to <c>true</c> [no cache].</param>
137
141
/// <param name="cancellationToken">The cancellation token for this async task.</param>
138
142
/// <returns></returns>
139
143
internal async Task < TcpServerConnection > GetServerConnection ( ProxyServer server , SessionEventArgsBase session , bool isConnect ,
@@ -168,6 +172,7 @@ internal async Task<TcpServerConnection> GetServerConnection(ProxyServer server,
168
172
/// <param name="applicationProtocols">The list of HTTPS application level protocol to negotiate if needed.</param>
169
173
/// <param name="isConnect">Is this a CONNECT request.</param>
170
174
/// <param name="proxyServer">The current ProxyServer instance.</param>
175
+ /// <param name="session">The session.</param>
171
176
/// <param name="upStreamEndPoint">The local upstream endpoint to make request via.</param>
172
177
/// <param name="externalProxy">The external proxy to make request via.</param>
173
178
/// <param name="noCache">Not from cache/create new connection.</param>
@@ -178,9 +183,9 @@ internal async Task<TcpServerConnection> GetServerConnection(string remoteHostNa
178
183
ProxyServer proxyServer , SessionEventArgsBase session , IPEndPoint upStreamEndPoint , ExternalProxy externalProxy ,
179
184
bool noCache , CancellationToken cancellationToken )
180
185
{
186
+ var sslProtocol = session . ProxyClient . Connection . SslProtocol ;
181
187
var cacheKey = GetConnectionCacheKey ( remoteHostName , remotePort ,
182
- isHttps , applicationProtocols ,
183
- proxyServer , upStreamEndPoint , externalProxy ) ;
188
+ isHttps , applicationProtocols , upStreamEndPoint , externalProxy ) ;
184
189
185
190
if ( proxyServer . EnableConnectionPool && ! noCache )
186
191
{
@@ -204,7 +209,7 @@ internal async Task<TcpServerConnection> GetServerConnection(string remoteHostNa
204
209
}
205
210
}
206
211
207
- var connection = await createServerConnection ( remoteHostName , remotePort , httpVersion , isHttps ,
212
+ var connection = await createServerConnection ( remoteHostName , remotePort , httpVersion , isHttps , sslProtocol ,
208
213
applicationProtocols , isConnect , proxyServer , session , upStreamEndPoint , externalProxy , cancellationToken ) ;
209
214
210
215
connection . CacheKey = cacheKey ;
@@ -219,6 +224,7 @@ internal async Task<TcpServerConnection> GetServerConnection(string remoteHostNa
219
224
/// <param name="remotePort">The remote port.</param>
220
225
/// <param name="httpVersion">The http version to use.</param>
221
226
/// <param name="isHttps">Is this a HTTPS request.</param>
227
+ /// <param name="sslProtocol">The SSL protocol.</param>
222
228
/// <param name="applicationProtocols">The list of HTTPS application level protocol to negotiate if needed.</param>
223
229
/// <param name="isConnect">Is this a CONNECT request.</param>
224
230
/// <param name="proxyServer">The current ProxyServer instance.</param>
@@ -228,7 +234,7 @@ internal async Task<TcpServerConnection> GetServerConnection(string remoteHostNa
228
234
/// <param name="cancellationToken">The cancellation token for this async task.</param>
229
235
/// <returns></returns>
230
236
private async Task < TcpServerConnection > createServerConnection ( string remoteHostName , int remotePort ,
231
- Version httpVersion , bool isHttps , List < SslApplicationProtocol > applicationProtocols , bool isConnect ,
237
+ Version httpVersion , bool isHttps , SslProtocols sslProtocol , List < SslApplicationProtocol > applicationProtocols , bool isConnect ,
232
238
ProxyServer proxyServer , SessionEventArgsBase session , IPEndPoint upStreamEndPoint , ExternalProxy externalProxy ,
233
239
CancellationToken cancellationToken )
234
240
{
@@ -269,7 +275,7 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
269
275
SslApplicationProtocol negotiatedApplicationProtocol = default ;
270
276
271
277
bool retry = true ;
272
- var enabledSslProtocols = proxyServer . SupportedSslProtocols ;
278
+ var enabledSslProtocols = sslProtocol ;
273
279
274
280
retry :
275
281
try
@@ -386,7 +392,7 @@ private async Task<TcpServerConnection> createServerConnection(string remoteHost
386
392
387
393
}
388
394
}
389
- catch ( IOException ex ) when ( ex . HResult == unchecked ( ( int ) 0x80131620 ) && retry )
395
+ catch ( IOException ex ) when ( ex . HResult == unchecked ( ( int ) 0x80131620 ) && retry && enabledSslProtocols >= SslProtocols . Tls11 )
390
396
{
391
397
enabledSslProtocols = SslProtocols . Tls ;
392
398
retry = false ;
0 commit comments