Skip to content

Commit 9f5cc4b

Browse files
committed
Don't use obsolete X509Certificate2 ctor
1 parent cfdb403 commit 9f5cc4b

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Microsoft.DotNet.Build.Tasks.Feed/src/PublishArtifactsInManifest.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ internal PublishArtifactsInManifestBase ConstructPublishingV3Task(BuildModel bui
352352
SkipSafetyChecks = this.SkipSafetyChecks,
353353
AkaMSClientId = this.AkaMSClientId,
354354
AkaMSClientCertificate = !string.IsNullOrEmpty(AkaMSClientCertificate) ?
355+
#if NET9_0_OR_GREATER
356+
X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate)), password: null) : null,
357+
#else
355358
new X509Certificate2(Convert.FromBase64String(File.ReadAllText(AkaMSClientCertificate))) : null,
359+
#endif
356360
AkaMSCreatedBy = this.AkaMSCreatedBy,
357361
AkaMSGroupOwner = this.AkaMSGroupOwner,
358362
AkaMsOwners = this.AkaMsOwners,

src/Microsoft.DotNet.Deployment.Tasks.Links/src/AkaMSLinksBase.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,11 @@ protected AkaMSLinkManager CreateAkaMSLinksManager()
2424
AkaMSLinkManager manager;
2525
if (!string.IsNullOrEmpty(ClientCertificate))
2626
{
27+
#if NET9_0_OR_GREATER
28+
manager = new AkaMSLinkManager(ClientId, X509CertificateLoader.LoadPkcs12(Convert.FromBase64String(File.ReadAllText(ClientCertificate)), password: null), Tenant, Log);
29+
#else
2730
manager = new AkaMSLinkManager(ClientId, new X509Certificate2(Convert.FromBase64String(File.ReadAllText(ClientCertificate))), Tenant, Log);
31+
#endif
2832
}
2933
else if (!string.IsNullOrEmpty(ClientSecret))
3034
{

0 commit comments

Comments
 (0)