Skip to content

Commit 3ea7632

Browse files
committed
Revert "Only run the cert validation on 45 or netstandard 2.0"
This reverts commit 6dcf543.
1 parent 6dcf543 commit 3ea7632

File tree

5 files changed

+15
-21
lines changed

5 files changed

+15
-21
lines changed

build/sourcelink.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
</PropertyGroup>
55

66
<ItemGroup>
7-
<PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.8.3" PrivateAssets="all" />
7+
<PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.8.1" PrivateAssets="all" />
88
</ItemGroup>
99
</Project>

src/Exceptionless/Configuration/CertificateData.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#if NET45 || NETSTANDARD2_0
2-
using System;
1+
#if !PORTABLE && !NETSTANDARD1_2
32
using System.Net.Http;
43
using System.Net.Security;
54
using System.Security.Cryptography.X509Certificates;
@@ -44,7 +43,9 @@ private CertificateData(X509Chain chain, SslPolicyErrors sslPolicyErrors) {
4443
/// An object that contains state information for this validation.
4544
/// </summary>
4645
public object Sender { get; }
47-
#else
46+
#endif
47+
48+
#if !NET45 && !PORTABLE && !NETSTANDARD1_2
4849
/// <summary>
4950
/// The request which was sent to the remore party
5051
/// </summary>

src/Exceptionless/Configuration/ExceptionlessConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ public int SubmissionBatchSize {
277277
}
278278
}
279279

280-
#if NET45 || NETSTANDARD2_0
280+
#if !PORTABLE && !NETSTANDARD1_2
281281
/// <summary>
282282
/// Callback which is invoked to validate the exceptionless server certificate.
283283
/// </summary>

src/Exceptionless/Extensions/ExceptionlessConfigurationExtensions.cs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -436,17 +436,15 @@ private static string GetEnvironmentalVariable(string name) {
436436
}
437437
#endif
438438

439-
#if NET45 || NETSTANDARD2_0
439+
#if !PORTABLE && !NETSTANDARD1_2
440440
/// <summary>
441441
/// Add a custom server certificate validation against the thumbprint of the server certificate.
442442
/// </summary>
443443
/// <param name="config">The configuration object you want to apply the attribute settings to.</param>
444444
/// <param name="thumbprint">Thumbprint of the server certificate. <example>e.g. "86481791CDAF6D7A02BEE9A649EA9F84DE84D22C"</example></param>
445445
public static void TrustCertificateThumbprint(this ExceptionlessConfiguration config, string thumbprint) {
446446
config.ServerCertificateValidationCallback = x => {
447-
if (x.SslPolicyErrors == SslPolicyErrors.None)
448-
return true;
449-
447+
if (x.SslPolicyErrors == SslPolicyErrors.None) return true;
450448
return x.Certificate != null && thumbprint != null && thumbprint.Equals(x.Certificate.Thumbprint, StringComparison.OrdinalIgnoreCase);
451449
};
452450
}
@@ -458,17 +456,12 @@ public static void TrustCertificateThumbprint(this ExceptionlessConfiguration co
458456
/// <param name="thumbprint">Thumbprint of the ca certificate. <example>e.g. "afe5d244a8d1194230ff479fe2f897bbcd7a8cb4"</example></param>
459457
public static void TrustCAThumbprint(this ExceptionlessConfiguration config, string thumbprint) {
460458
config.ServerCertificateValidationCallback = x => {
461-
if (x.SslPolicyErrors == SslPolicyErrors.None)
462-
return true;
463-
464-
if (x.Chain == null || thumbprint == null)
465-
return false;
466-
459+
if (x.SslPolicyErrors == SslPolicyErrors.None) return true;
460+
if (x.Chain == null || thumbprint == null) return false;
467461
foreach (var ca in x.Chain.ChainElements) {
468462
if (thumbprint.Equals(ca.Certificate.Thumbprint, StringComparison.OrdinalIgnoreCase))
469463
return true;
470464
}
471-
472465
return false;
473466
};
474467
}

src/Exceptionless/Submission/DefaultSubmissionClient.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Net;
55
using System.Net.Http;
66
using System.Net.Http.Headers;
7-
#if NET45 || NETSTANDARD2_0
7+
#if NET45 || (!PORTABLE && !NETSTANDARD1_2)
88
using System.Net.Security;
99
using System.Security.Cryptography.X509Certificates;
1010
#endif
@@ -130,13 +130,13 @@ protected virtual HttpClient CreateHttpClient(ExceptionlessConfiguration config)
130130
#else
131131
var handler = new HttpClientHandler { UseDefaultCredentials = true };
132132
#endif
133-
#if NET45 || NETSTANDARD2_0
133+
#if !PORTABLE && !NETSTANDARD1_2
134134
var callback = config.ServerCertificateValidationCallback;
135135
if (callback != null) {
136136
#if NET45
137-
handler.ServerCertificateValidationCallback = (s,c,ch,p) => Validate(s,c,ch,p,callback);
137+
handler.ServerCertificateValidationCallback = (s,c,ch,p)=>Validate(s,c,ch,p,callback);
138138
#else
139-
handler.ServerCertificateCustomValidationCallback = (m,c,ch,p) => Validate(m,c,ch,p,callback);
139+
handler.ServerCertificateCustomValidationCallback = (m,c,ch,p)=>Validate(m,c,ch,p,callback);
140140
#endif
141141
}
142142
#endif
@@ -157,7 +157,7 @@ protected virtual HttpClient CreateHttpClient(ExceptionlessConfiguration config)
157157
return client;
158158
}
159159

160-
#if NET45 || NETSTANDARD2_0
160+
#if !PORTABLE && !NETSTANDARD1_2
161161
#if NET45
162162
private bool Validate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors, Func<CertificateData, bool> callback) {
163163
var certData = new CertificateData(sender, certificate, chain, sslPolicyErrors);

0 commit comments

Comments
 (0)