From b907c60b5600e5509f1887ad2856fa1c0681de87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sun, 13 Oct 2024 14:22:03 +0200 Subject: [PATCH 1/2] Revert "Suppress SYSLIB0057 for now (#14937)" This reverts commit a3bb96d0da69d3cdb9e83122e6139b32fc324c44. --- .../src/PublishArtifactsInManifest.cs | 2 -- .../src/AkaMSLinksBase.cs | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs index 8599fb00d82..ce67b61eede 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs @@ -361,9 +361,7 @@ internal PublishArtifactsInManifestBase ConstructPublishingV3Task(BuildModel bui SkipSafetyChecks = this.SkipSafetyChecks, AkaMSClientId = this.AkaMSClientId, AkaMSClientCertificate = !string.IsNullOrEmpty(AkaMSClientCertificate) ? -#pragma warning disable SYSLIB0057 // https://github.com/dotnet/arcade/issues/14936 new X509Certificate2(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate))) : null, -#pragma warning restore AkaMSCreatedBy = this.AkaMSCreatedBy, AkaMSGroupOwner = this.AkaMSGroupOwner, AkaMsOwners = this.AkaMsOwners, diff --git a/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs b/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs index 927d5037a71..013ea538c98 100644 --- a/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs +++ b/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs @@ -24,9 +24,7 @@ protected AkaMSLinkManager CreateAkaMSLinksManager() AkaMSLinkManager manager; if (!string.IsNullOrEmpty(ClientCertificate)) { -#pragma warning disable SYSLIB0057 // https://github.com/dotnet/arcade/issues/14936 manager = new AkaMSLinkManager(ClientId, new X509Certificate2(Convert.FromBase64String(File.ReadAllText(ClientCertificate))), Tenant, Log); -#pragma warning restore } else if (!string.IsNullOrEmpty(ClientSecret)) { From f39ccece913d3926836aec39577479a5504c0777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20K=C3=B6plinger?= Date: Sun, 13 Oct 2024 14:22:34 +0200 Subject: [PATCH 2/2] Don't use obsolete X509Certificate2 ctor --- .../src/PublishArtifactsInManifest.cs | 4 ++++ .../src/AkaMSLinksBase.cs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs index ce67b61eede..950220c363d 100644 --- a/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs +++ b/src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs @@ -361,7 +361,11 @@ internal PublishArtifactsInManifestBase ConstructPublishingV3Task(BuildModel bui SkipSafetyChecks = this.SkipSafetyChecks, AkaMSClientId = this.AkaMSClientId, AkaMSClientCertificate = !string.IsNullOrEmpty(AkaMSClientCertificate) ? +#if NET9_0_OR_GREATER + X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate)), password: null) : null, +#else new X509Certificate2(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate))) : null, +#endif AkaMSCreatedBy = this.AkaMSCreatedBy, AkaMSGroupOwner = this.AkaMSGroupOwner, AkaMsOwners = this.AkaMsOwners, diff --git a/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs b/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs index 013ea538c98..77a64125333 100644 --- a/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs +++ b/src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs @@ -24,7 +24,11 @@ protected AkaMSLinkManager CreateAkaMSLinksManager() AkaMSLinkManager manager; if (!string.IsNullOrEmpty(ClientCertificate)) { +#if NET9_0_OR_GREATER + manager = new AkaMSLinkManager(ClientId, X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(File.ReadAllText(ClientCertificate)), password: null), Tenant, Log); +#else manager = new AkaMSLinkManager(ClientId, new X509Certificate2(Convert.FromBase64String(File.ReadAllText(ClientCertificate))), Tenant, Log); +#endif } else if (!string.IsNullOrEmpty(ClientSecret)) {