Skip to content

Commit 42ca3f9

Browse files
author
Tien Nguyen
committed
Remove the need to have custom local RemoteCertificateValidationCallback and use the microsoft version instead after address the depdency conflict in test project
1 parent 912cebf commit 42ca3f9

File tree

6 files changed

+9
-13
lines changed

6 files changed

+9
-13
lines changed

src/AdoNetCore.AseClient/AseConnection.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Data;
44
using System.Data.Common;
55
using System.Net.Security;
6-
using System.Security.Cryptography.X509Certificates;
76
using AdoNetCore.AseClient.Interface;
87
using AdoNetCore.AseClient.Internal;
98

@@ -676,14 +675,4 @@ public AseTransaction Transaction
676675
/// the TraceEnter and TraceExit events.</para>
677676
/// </remarks>
678677
public delegate void TraceExitEventHandler(AseConnection connection, object source, string method, object returnValue);
679-
680-
/// <summary>
681-
/// Verifies the remote Secure Sockets Layer (SSL) certificate used for authentication.
682-
/// </summary>
683-
/// <param name="sender">An object that contains state information for this validation.</param>
684-
/// <param name="certificate">The certificate used to authenticate the remote party.</param>
685-
/// <param name="chain">The chain of certificate authorities associated with the remote certificate.</param>
686-
/// <param name="sslPolicyErrors">One or more errors associated with the remote certificate.</param>
687-
/// <returns>A System.Boolean value that determines whether the specified certificate is accepted for authentication.</returns>
688-
public delegate bool RemoteCertificateValidationCallback(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors);
689678
}

src/AdoNetCore.AseClient/Interface/IConnectionPoolManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
using System.Net.Security;
2+
13
namespace AdoNetCore.AseClient.Interface
24
{
35
internal interface IConnectionPoolManager

src/AdoNetCore.AseClient/Internal/ConnectionPoolManager.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections;
33
using System.Collections.Concurrent;
44
using System.Collections.Generic;
5+
using System.Net.Security;
56
using AdoNetCore.AseClient.Interface;
67

78
namespace AdoNetCore.AseClient.Internal

src/AdoNetCore.AseClient/Internal/InternalConnectionFactory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace AdoNetCore.AseClient.Internal
1919
internal class InternalConnectionFactory : IInternalConnectionFactory
2020
{
2121
private readonly IConnectionParameters _parameters;
22-
private readonly System.Net.Security.RemoteCertificateValidationCallback _userCertificateValidationCallback;
22+
private readonly RemoteCertificateValidationCallback _userCertificateValidationCallback;
2323

2424

2525
#if ENABLE_ARRAY_POOL
@@ -34,7 +34,7 @@ public InternalConnectionFactory(IConnectionParameters parameters, RemoteCertifi
3434
#endif
3535
{
3636
_parameters = parameters;
37-
_userCertificateValidationCallback = userCertificateValidationCallback == null ? UserCertificateValidationCallback : new System.Net.Security.RemoteCertificateValidationCallback(userCertificateValidationCallback);
37+
_userCertificateValidationCallback = userCertificateValidationCallback ?? UserCertificateValidationCallback;
3838

3939
#if ENABLE_ARRAY_POOL
4040
_arrayPool = arrayPool;

test/AdoNetCore.AseClient.Tests/AdoNetCore.AseClient.Tests.csproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
1111
<PackageReference Include="NUnit" Version="3.12.0" />
1212
<PackageReference Include="NUnit3TestAdapter" Version="3.13.0" />
13+
1314
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
1415
</ItemGroup>
1516
<ItemGroup>
@@ -34,9 +35,11 @@
3435
</PropertyGroup>
3536
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' ">
3637
<PackageReference Include="System.Data.Common" Version="4.3.0" />
38+
<PackageReference Include="System.Net.Security" Version="4.3.2" />
3739
</ItemGroup>
3840
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">
3941
<PackageReference Include="System.Data.Common" Version="4.3.0" />
42+
<PackageReference Include="System.Net.Security" Version="4.3.2" />
4043
</ItemGroup>
4144
<ItemGroup Condition="'$(TargetFramework)' == 'net46'">
4245
<PackageReference Include="Sybase.AdoNet4.AseClient">

test/AdoNetCore.AseClient.Tests/Unit/AseConnectionTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Data;
3+
using System.Net.Security;
34
using AdoNetCore.AseClient.Interface;
45
using AdoNetCore.AseClient.Internal;
56
using Moq;

0 commit comments

Comments
 (0)