From c0ddf0f0a2437262ed9837cd70497c39671c74f6 Mon Sep 17 00:00:00 2001
From: Radek Zikmund <32671551+rzikm@users.noreply.github.com>
Date: Tue, 19 Jul 2022 09:00:06 +0200
Subject: [PATCH] Use TlsAlertMessage enum to make exception messages more
readable (#72370)
---
.../src/System/Net/Security/TlsAlertMessage.cs | 0
src/libraries/System.Net.Quic/src/System.Net.Quic.csproj | 2 ++
.../src/System/Net/Quic/Internal/ThrowHelper.cs | 3 ++-
.../System.Net.Security/src/System.Net.Security.csproj | 3 ++-
.../tests/UnitTests/System.Net.Security.Unit.Tests.csproj | 4 ++--
5 files changed, 8 insertions(+), 4 deletions(-)
rename src/libraries/{System.Net.Security => Common}/src/System/Net/Security/TlsAlertMessage.cs (100%)
diff --git a/src/libraries/System.Net.Security/src/System/Net/Security/TlsAlertMessage.cs b/src/libraries/Common/src/System/Net/Security/TlsAlertMessage.cs
similarity index 100%
rename from src/libraries/System.Net.Security/src/System/Net/Security/TlsAlertMessage.cs
rename to src/libraries/Common/src/System/Net/Security/TlsAlertMessage.cs
diff --git a/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj b/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
index 2511b13f92237..4eb9f5135b4ba 100644
--- a/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
+++ b/src/libraries/System.Net.Quic/src/System.Net.Quic.csproj
@@ -27,6 +27,8 @@
+
diff --git a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ThrowHelper.cs b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ThrowHelper.cs
index 01a6fd9806df9..ef6223912e9ac 100644
--- a/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ThrowHelper.cs
+++ b/src/libraries/System.Net.Quic/src/System/Net/Quic/Internal/ThrowHelper.cs
@@ -3,6 +3,7 @@
using Microsoft.Quic;
using System.Security.Authentication;
+using System.Net.Security;
using static Microsoft.Quic.MsQuic;
namespace System.Net.Quic;
@@ -89,7 +90,7 @@ static Exception GetExceptionInternal(int status, string? message)
//
if ((uint)status >= (uint)QUIC_STATUS_CLOSE_NOTIFY && (uint)status < (uint)QUIC_STATUS_CLOSE_NOTIFY + 256)
{
- int alert = status - QUIC_STATUS_CLOSE_NOTIFY;
+ TlsAlertMessage alert = (TlsAlertMessage)(status - QUIC_STATUS_CLOSE_NOTIFY);
return new AuthenticationException(SR.Format(SR.net_auth_tls_alert, alert));
}
diff --git a/src/libraries/System.Net.Security/src/System.Net.Security.csproj b/src/libraries/System.Net.Security/src/System.Net.Security.csproj
index 139ea7ce4ba06..eba0ccf4e454a 100644
--- a/src/libraries/System.Net.Security/src/System.Net.Security.csproj
+++ b/src/libraries/System.Net.Security/src/System.Net.Security.csproj
@@ -46,7 +46,6 @@
-
@@ -84,6 +83,8 @@
Link="Common\System\NotImplemented.cs" />
+
+
-