Skip to content

Commit 4ab9be1

Browse files
committed
Merge CreatePhysicalSNIHandle
1 parent dfeb360 commit 4ab9be1

File tree

4 files changed

+67
-64
lines changed

4 files changed

+67
-64
lines changed

src/Microsoft.Data.SqlClient/netcore/src/Microsoft/Data/SqlClient/TdsParserStateObject.netcore.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,6 @@ protected TdsParserStateObject(TdsParser parser, TdsParserStateObject physicalCo
6767
// General methods //
6868
/////////////////////
6969

70-
internal abstract void CreatePhysicalSNIHandle(
71-
string serverName,
72-
TimeoutTimer timeout,
73-
out byte[] instanceName,
74-
ref string[] spns,
75-
bool flushCache,
76-
bool async,
77-
bool fParallel,
78-
TransparentNetworkResolutionState transparentNetworkResolutionState,
79-
int totalTimeout,
80-
SqlConnectionIPAddressPreference iPAddressPreference,
81-
string cachedFQDN,
82-
ref SQLDNSInfo pendingDNSInfo,
83-
string serverSPN,
84-
bool isIntegratedSecurity = false,
85-
bool tlsFirst = false,
86-
string hostNameInCertificate = "",
87-
string serverCertificateFilename = "");
88-
8970
protected abstract void FreeGcHandle(int remaining, bool release);
9071

9172
internal abstract uint EnableSsl(ref uint info, bool tlsFirst, string serverCertificateFilename);

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObject.netfx.cs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -104,51 +104,6 @@ protected ConsumerInfo CreateConsumerInfo(bool async)
104104
return myInfo;
105105
}
106106

107-
internal void CreatePhysicalSNIHandle(
108-
string serverName,
109-
TimeoutTimer timeout,
110-
out byte[] instanceName,
111-
ref string[] spns,
112-
bool flushCache,
113-
bool async,
114-
bool fParallel,
115-
TransparentNetworkResolutionState transparentNetworkResolutionState,
116-
int totalTimeout,
117-
SqlConnectionIPAddressPreference iPAddressPreference,
118-
string cachedFQDN,
119-
ref SQLDNSInfo pendingDNSInfo,
120-
string serverSPN,
121-
bool isIntegratedSecurity = false,
122-
bool tlsFirst = false,
123-
string hostNameInCertificate = "",
124-
string serverCertificateFilename = "")
125-
{
126-
if (isIntegratedSecurity)
127-
{
128-
if (!string.IsNullOrEmpty(serverSPN))
129-
{
130-
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Server SPN `{0}` from the connection string is used.", serverSPN);
131-
}
132-
else
133-
{
134-
// Empty signifies to interop layer that SPN needs to be generated
135-
serverSPN = string.Empty;
136-
}
137-
}
138-
139-
ConsumerInfo myInfo = CreateConsumerInfo(async);
140-
141-
// serverName : serverInfo.ExtendedServerName
142-
// may not use this serverName as key
143-
144-
_ = SQLFallbackDNSCache.Instance.GetDNSInfo(cachedFQDN, out SQLDNSInfo cachedDNSInfo);
145-
146-
_sessionHandle = new SNIHandle(myInfo, serverName, ref serverSPN, timeout.MillisecondsRemainingInt,
147-
out instanceName, flushCache, !async, fParallel, transparentNetworkResolutionState, totalTimeout,
148-
iPAddressPreference, cachedDNSInfo, hostNameInCertificate);
149-
spns = new[] { serverSPN.TrimEnd() };
150-
}
151-
152107
internal uint CheckConnection() => SniNativeWrapper.SniCheckConnection(Handle);
153108

154109
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.Success)]

src/Microsoft.Data.SqlClient/netfx/src/Microsoft/Data/SqlClient/TdsParserStateObjectNative.cs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System.Threading.Tasks;
1111
using Interop.Windows.Sni;
1212
using Microsoft.Data.Common;
13+
using Microsoft.Data.ProviderBase;
1314

1415
namespace Microsoft.Data.SqlClient
1516
{
@@ -106,6 +107,51 @@ internal override void AssignPendingDNSInfo(string userProtocol, string DNSCache
106107
}
107108
}
108109

110+
internal override void CreatePhysicalSNIHandle(
111+
string serverName,
112+
TimeoutTimer timeout,
113+
out byte[] instanceName,
114+
ref string[] spns,
115+
bool flushCache,
116+
bool async,
117+
bool fParallel,
118+
TransparentNetworkResolutionState transparentNetworkResolutionState,
119+
int totalTimeout,
120+
SqlConnectionIPAddressPreference iPAddressPreference,
121+
string cachedFQDN,
122+
ref SQLDNSInfo pendingDNSInfo,
123+
string serverSPN,
124+
bool isIntegratedSecurity = false,
125+
bool tlsFirst = false,
126+
string hostNameInCertificate = "",
127+
string serverCertificateFilename = "")
128+
{
129+
if (isIntegratedSecurity)
130+
{
131+
if (!string.IsNullOrEmpty(serverSPN))
132+
{
133+
SqlClientEventSource.Log.TryTraceEvent("<sc.TdsParser.Connect|SEC> Server SPN `{0}` from the connection string is used.", serverSPN);
134+
}
135+
else
136+
{
137+
// Empty signifies to interop layer that SPN needs to be generated
138+
serverSPN = string.Empty;
139+
}
140+
}
141+
142+
ConsumerInfo myInfo = CreateConsumerInfo(async);
143+
144+
// serverName : serverInfo.ExtendedServerName
145+
// may not use this serverName as key
146+
147+
_ = SQLFallbackDNSCache.Instance.GetDNSInfo(cachedFQDN, out SQLDNSInfo cachedDNSInfo);
148+
149+
_sessionHandle = new SNIHandle(myInfo, serverName, ref serverSPN, timeout.MillisecondsRemainingInt,
150+
out instanceName, flushCache, !async, fParallel, transparentNetworkResolutionState, totalTimeout,
151+
iPAddressPreference, cachedDNSInfo, hostNameInCertificate);
152+
spns = new[] { serverSPN.TrimEnd() };
153+
}
154+
109155
protected override uint SniPacketGetData(PacketHandle packet, byte[] _inBuff, ref uint dataSize)
110156
{
111157
Debug.Assert(packet.Type == PacketHandle.NativePointerType, "unexpected packet type when requiring NativePointer");

src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/TdsParserStateObject.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
using System.Threading;
1313
using System.Threading.Tasks;
1414
using Microsoft.Data.Common;
15+
using Microsoft.Data.ProviderBase;
16+
1517
#if NETFRAMEWORK
1618
using System.Runtime.ConstrainedExecution;
1719
#endif
@@ -487,6 +489,25 @@ internal long TimeoutTime
487489

488490
internal abstract void AssignPendingDNSInfo(string userProtocol, string DNSCacheKey, ref SQLDNSInfo pendingDNSInfo);
489491

492+
internal abstract void CreatePhysicalSNIHandle(
493+
string serverName,
494+
TimeoutTimer timeout,
495+
out byte[] instanceName,
496+
ref string[] spns,
497+
bool flushCache,
498+
bool async,
499+
bool fParallel,
500+
TransparentNetworkResolutionState transparentNetworkResolutionState,
501+
int totalTimeout,
502+
SqlConnectionIPAddressPreference iPAddressPreference,
503+
string cachedFQDN,
504+
ref SQLDNSInfo pendingDNSInfo,
505+
string serverSPN,
506+
bool isIntegratedSecurity = false,
507+
bool tlsFirst = false,
508+
string hostNameInCertificate = "",
509+
string serverCertificateFilename = "");
510+
490511
internal abstract PacketHandle GetResetWritePacket(int dataSize);
491512

492513
protected abstract uint SniPacketGetData(PacketHandle packet, byte[] _inBuff, ref uint dataSize);

0 commit comments

Comments
 (0)