@@ -32,38 +32,6 @@ internal class SspiClientContextResult
32
32
33
33
internal static SNIProxy GetInstance ( ) => s_singleton ;
34
34
35
- /// <summary>
36
- /// Enable SSL on a connection
37
- /// </summary>
38
- /// <param name="handle">Connection handle</param>
39
- /// <param name="options"></param>
40
- /// <returns>SNI error code</returns>
41
- internal uint EnableSsl ( SNIHandle handle , uint options )
42
- {
43
- try
44
- {
45
- SqlClientEventSource . Log . TryTraceEvent ( "SNIProxy.EnableSsl | Info | Session Id {0}" , handle ? . ConnectionId ) ;
46
- return handle . EnableSsl ( options ) ;
47
- }
48
- catch ( Exception e )
49
- {
50
- SqlClientEventSource . Log . TryTraceEvent ( "SNIProxy.EnableSsl | Err | Session Id {0}, SNI Handshake failed with exception: {1}" , handle ? . ConnectionId , e ? . Message ) ;
51
- return SNICommon . ReportSNIError ( SNIProviders . SSL_PROV , SNICommon . HandshakeFailureError , e ) ;
52
- }
53
- }
54
-
55
- /// <summary>
56
- /// Disable SSL on a connection
57
- /// </summary>
58
- /// <param name="handle">Connection handle</param>
59
- /// <returns>SNI error code</returns>
60
- internal uint DisableSsl ( SNIHandle handle )
61
- {
62
- SqlClientEventSource . Log . TryTraceEvent ( "SNIProxy.DisableSsl | Info | Session Id {0}" , handle ? . ConnectionId ) ;
63
- handle . DisableSsl ( ) ;
64
- return TdsEnums . SNI_SUCCESS ;
65
- }
66
-
67
35
/// <summary>
68
36
/// Generate SSPI context
69
37
/// </summary>
@@ -72,7 +40,7 @@ internal uint DisableSsl(SNIHandle handle)
72
40
/// <param name="sendBuff">Send buffer</param>
73
41
/// <param name="serverName">Service Principal Name buffer</param>
74
42
/// <returns>SNI error code</returns>
75
- internal void GenSspiClientContext ( SspiClientContextStatus sspiClientContextStatus , byte [ ] receivedBuff , ref byte [ ] sendBuff , byte [ ] [ ] serverName )
43
+ internal static void GenSspiClientContext ( SspiClientContextStatus sspiClientContextStatus , byte [ ] receivedBuff , ref byte [ ] sendBuff , byte [ ] [ ] serverName )
76
44
{
77
45
SafeDeleteContext securityContext = sspiClientContextStatus . SecurityContext ;
78
46
ContextFlagsPal contextFlags = sspiClientContextStatus . ContextFlags ;
@@ -165,83 +133,6 @@ private static bool IsErrorStatus(SecurityStatusPalErrorCode errorCode)
165
133
errorCode != SecurityStatusPalErrorCode . Renegotiate ;
166
134
}
167
135
168
- /// <summary>
169
- /// Set connection buffer size
170
- /// </summary>
171
- /// <param name="handle">SNI handle</param>
172
- /// <param name="bufferSize">Buffer size</param>
173
- /// <returns>SNI error code</returns>
174
- internal uint SetConnectionBufferSize ( SNIHandle handle , uint bufferSize )
175
- {
176
- handle . SetBufferSize ( ( int ) bufferSize ) ;
177
- return TdsEnums . SNI_SUCCESS ;
178
- }
179
-
180
- /// <summary>
181
- /// Copies data in SNIPacket to given byte array parameter
182
- /// </summary>
183
- /// <param name="packet">SNIPacket object containing data packets</param>
184
- /// <param name="inBuff">Destination byte array where data packets are copied to</param>
185
- /// <param name="dataSize">Length of data packets</param>
186
- /// <returns>SNI error status</returns>
187
- internal uint PacketGetData ( SNIPacket packet , byte [ ] inBuff , ref uint dataSize )
188
- {
189
- int dataSizeInt = 0 ;
190
- packet . GetData ( inBuff , ref dataSizeInt ) ;
191
- dataSize = ( uint ) dataSizeInt ;
192
-
193
- return TdsEnums . SNI_SUCCESS ;
194
- }
195
-
196
- /// <summary>
197
- /// Read synchronously
198
- /// </summary>
199
- /// <param name="handle">SNI handle</param>
200
- /// <param name="packet">SNI packet</param>
201
- /// <param name="timeout">Timeout</param>
202
- /// <returns>SNI error status</returns>
203
- internal uint ReadSyncOverAsync ( SNIHandle handle , out SNIPacket packet , int timeout )
204
- {
205
- return handle . Receive ( out packet , timeout ) ;
206
- }
207
-
208
- /// <summary>
209
- /// Get SNI connection ID
210
- /// </summary>
211
- /// <param name="handle">SNI handle</param>
212
- /// <param name="clientConnectionId">Client connection ID</param>
213
- /// <returns>SNI error status</returns>
214
- internal uint GetConnectionId ( SNIHandle handle , ref Guid clientConnectionId )
215
- {
216
- clientConnectionId = handle . ConnectionId ;
217
- SqlClientEventSource . Log . TryTraceEvent ( "SNIProxy.GetConnectionId | Info | Session Id {0}" , clientConnectionId ) ;
218
- return TdsEnums . SNI_SUCCESS ;
219
- }
220
-
221
- /// <summary>
222
- /// Send a packet
223
- /// </summary>
224
- /// <param name="handle">SNI handle</param>
225
- /// <param name="packet">SNI packet</param>
226
- /// <param name="sync">true if synchronous, false if asynchronous</param>
227
- /// <returns>SNI error status</returns>
228
- internal uint WritePacket ( SNIHandle handle , SNIPacket packet , bool sync )
229
- {
230
- uint result ;
231
- if ( sync )
232
- {
233
- result = handle . Send ( packet ) ;
234
- handle . ReturnPacket ( packet ) ;
235
- }
236
- else
237
- {
238
- result = handle . SendAsync ( packet ) ;
239
- }
240
-
241
- SqlClientEventSource . Log . TryTraceEvent ( "SNIProxy.WritePacket | Info | Session Id {0}, SendAsync Result {1}" , handle ? . ConnectionId , result ) ;
242
- return result ;
243
- }
244
-
245
136
/// <summary>
246
137
/// Create a SNI connection handle
247
138
/// </summary>
@@ -257,7 +148,7 @@ internal uint WritePacket(SNIHandle handle, SNIPacket packet, bool sync)
257
148
/// <param name="cachedFQDN">Used for DNS Cache</param>
258
149
/// <param name="pendingDNSInfo">Used for DNS Cache</param>
259
150
/// <returns>SNI handle</returns>
260
- internal SNIHandle CreateConnectionHandle ( string fullServerName , bool ignoreSniOpenTimeout , long timerExpire , out byte [ ] instanceName , ref byte [ ] [ ] spnBuffer , bool flushCache , bool async , bool parallel , bool isIntegratedSecurity , string cachedFQDN , ref SQLDNSInfo pendingDNSInfo )
151
+ internal static SNIHandle CreateConnectionHandle ( string fullServerName , bool ignoreSniOpenTimeout , long timerExpire , out byte [ ] instanceName , ref byte [ ] [ ] spnBuffer , bool flushCache , bool async , bool parallel , bool isIntegratedSecurity , string cachedFQDN , ref SQLDNSInfo pendingDNSInfo )
261
152
{
262
153
instanceName = new byte [ 1 ] ;
263
154
@@ -377,7 +268,7 @@ private static byte[][] GetSqlServerSPNs(string hostNameOrAddress, string portOr
377
268
/// <param name="cachedFQDN">Key for DNS Cache</param>
378
269
/// <param name="pendingDNSInfo">Used for DNS Cache</param>
379
270
/// <returns>SNITCPHandle</returns>
380
- private SNITCPHandle CreateTcpHandle ( DataSource details , long timerExpire , bool parallel , string cachedFQDN , ref SQLDNSInfo pendingDNSInfo )
271
+ private static SNITCPHandle CreateTcpHandle ( DataSource details , long timerExpire , bool parallel , string cachedFQDN , ref SQLDNSInfo pendingDNSInfo )
381
272
{
382
273
// TCP Format:
383
274
// tcp:<host name>\<instance name>
@@ -418,16 +309,14 @@ private SNITCPHandle CreateTcpHandle(DataSource details, long timerExpire, bool
418
309
return new SNITCPHandle ( hostName , port , timerExpire , parallel , cachedFQDN , ref pendingDNSInfo ) ;
419
310
}
420
311
421
-
422
-
423
312
/// <summary>
424
313
/// Creates an SNINpHandle object
425
314
/// </summary>
426
315
/// <param name="details">Data source</param>
427
316
/// <param name="timerExpire">Timer expiration</param>
428
317
/// <param name="parallel">Should MultiSubnetFailover be used. Only returns an error for named pipes.</param>
429
318
/// <returns>SNINpHandle</returns>
430
- private SNINpHandle CreateNpHandle ( DataSource details , long timerExpire , bool parallel )
319
+ private static SNINpHandle CreateNpHandle ( DataSource details , long timerExpire , bool parallel )
431
320
{
432
321
if ( parallel )
433
322
{
@@ -438,39 +327,6 @@ private SNINpHandle CreateNpHandle(DataSource details, long timerExpire, bool pa
438
327
return new SNINpHandle ( details . PipeHostName , details . PipeName , timerExpire ) ;
439
328
}
440
329
441
- /// <summary>
442
- /// Read packet asynchronously
443
- /// </summary>
444
- /// <param name="handle">SNI handle</param>
445
- /// <param name="packet">Packet</param>
446
- /// <returns>SNI error status</returns>
447
- internal uint ReadAsync ( SNIHandle handle , out SNIPacket packet )
448
- {
449
- packet = null ;
450
- return handle . ReceiveAsync ( ref packet ) ;
451
- }
452
-
453
- /// <summary>
454
- /// Set packet data
455
- /// </summary>
456
- /// <param name="packet">SNI packet</param>
457
- /// <param name="data">Data</param>
458
- /// <param name="length">Length</param>
459
- internal void PacketSetData ( SNIPacket packet , byte [ ] data , int length )
460
- {
461
- packet . AppendData ( data , length ) ;
462
- }
463
-
464
- /// <summary>
465
- /// Check SNI handle connection
466
- /// </summary>
467
- /// <param name="handle"></param>
468
- /// <returns>SNI error status</returns>
469
- internal uint CheckConnection ( SNIHandle handle )
470
- {
471
- return handle . CheckConnection ( ) ;
472
- }
473
-
474
330
/// <summary>
475
331
/// Get last SNI error on this thread
476
332
/// </summary>
@@ -486,7 +342,7 @@ internal SNIError GetLastError()
486
342
/// <param name="fullServerName">The data source</param>
487
343
/// <param name="error">Set true when an error occurred while getting LocalDB up</param>
488
344
/// <returns></returns>
489
- private string GetLocalDBDataSource ( string fullServerName , out bool error )
345
+ private static string GetLocalDBDataSource ( string fullServerName , out bool error )
490
346
{
491
347
string localDBConnectionString = null ;
492
348
bool isBadLocalDBDataSource ;
0 commit comments