4
4
5
5
using System ;
6
6
using System . Buffers ;
7
+ using System . Collections . Generic ;
7
8
using System . Diagnostics ;
8
9
using System . IO ;
9
10
using System . Net ;
@@ -33,7 +34,7 @@ internal class SNIProxy
33
34
/// <param name="fullServerName">Full server name from connection string</param>
34
35
/// <param name="timeout">Timer expiration</param>
35
36
/// <param name="instanceName">Instance name</param>
36
- /// <param name="spnBuffer">SPN </param>
37
+ /// <param name="spns">SPNs </param>
37
38
/// <param name="serverSPN">pre-defined SPN</param>
38
39
/// <param name="flushCache">Flush packet cache</param>
39
40
/// <param name="async">Asynchronous connection</param>
@@ -50,7 +51,7 @@ internal static SNIHandle CreateConnectionHandle(
50
51
string fullServerName ,
51
52
TimeoutTimer timeout ,
52
53
out byte [ ] instanceName ,
53
- ref byte [ ] [ ] spnBuffer ,
54
+ ref string [ ] spns ,
54
55
string serverSPN ,
55
56
bool flushCache ,
56
57
bool async ,
@@ -102,7 +103,7 @@ internal static SNIHandle CreateConnectionHandle(
102
103
{
103
104
try
104
105
{
105
- spnBuffer = GetSqlServerSPNs ( details , serverSPN ) ;
106
+ spns = GetSqlServerSPNs ( details , serverSPN ) ;
106
107
}
107
108
catch ( Exception e )
108
109
{
@@ -114,12 +115,12 @@ internal static SNIHandle CreateConnectionHandle(
114
115
return sniHandle ;
115
116
}
116
117
117
- private static byte [ ] [ ] GetSqlServerSPNs ( DataSource dataSource , string serverSPN )
118
+ private static string [ ] GetSqlServerSPNs ( DataSource dataSource , string serverSPN )
118
119
{
119
120
Debug . Assert ( ! string . IsNullOrWhiteSpace ( dataSource . ServerName ) ) ;
120
121
if ( ! string . IsNullOrWhiteSpace ( serverSPN ) )
121
122
{
122
- return new byte [ 1 ] [ ] { Encoding . Unicode . GetBytes ( serverSPN ) } ;
123
+ return new [ ] { serverSPN } ;
123
124
}
124
125
125
126
string hostName = dataSource . ServerName ;
@@ -137,7 +138,7 @@ private static byte[][] GetSqlServerSPNs(DataSource dataSource, string serverSPN
137
138
return GetSqlServerSPNs ( hostName , postfix , dataSource . ResolvedProtocol ) ;
138
139
}
139
140
140
- private static byte [ ] [ ] GetSqlServerSPNs ( string hostNameOrAddress , string portOrInstanceName , DataSource . Protocol protocol )
141
+ private static string [ ] GetSqlServerSPNs ( string hostNameOrAddress , string portOrInstanceName , DataSource . Protocol protocol )
141
142
{
142
143
Debug . Assert ( ! string . IsNullOrWhiteSpace ( hostNameOrAddress ) ) ;
143
144
IPHostEntry hostEntry = null ;
@@ -168,12 +169,12 @@ private static byte[][] GetSqlServerSPNs(string hostNameOrAddress, string portOr
168
169
string serverSpnWithDefaultPort = serverSpn + $ ":{ DefaultSqlServerPort } ";
169
170
// Set both SPNs with and without Port as Port is optional for default instance
170
171
SqlClientEventSource . Log . TryAdvancedTraceEvent ( "SNIProxy.GetSqlServerSPN | Info | ServerSPNs {0} and {1}" , serverSpn , serverSpnWithDefaultPort ) ;
171
- return new byte [ ] [ ] { Encoding . Unicode . GetBytes ( serverSpn ) , Encoding . Unicode . GetBytes ( serverSpnWithDefaultPort ) } ;
172
+ return new [ ] { serverSpn , serverSpnWithDefaultPort } ;
172
173
}
173
174
// else Named Pipes do not need to valid port
174
175
175
176
SqlClientEventSource . Log . TryAdvancedTraceEvent ( "SNIProxy.GetSqlServerSPN | Info | ServerSPN {0}" , serverSpn ) ;
176
- return new byte [ ] [ ] { Encoding . Unicode . GetBytes ( serverSpn ) } ;
177
+ return new [ ] { serverSpn } ;
177
178
}
178
179
179
180
/// <summary>
0 commit comments