⚡ Sangsakala Proxy 🏠 Home
Skip to content

Replace the deprecated X509Certificate2 constructor with X509CertificateLoader.LoadCertificate - #27965

Merged
Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:msrc-serialization
Sep 22, 2026
Merged

Dongbo Wang (daxian-dbw) merged 1 commit into
PowerShell:masterfrom
daxian-dbw:msrc-serialization

Conversation

@daxian-dbw

Copy link
Copy Markdown
Member

PR Summary

Replace the deprecated X509Certificate2 constructor with X509CertificateLoader.LoadCertificate in PowerShell.

PR Checklist

@daxian-dbw
Dongbo Wang (daxian-dbw) requested a review from a team as a code owner September 3, 2026 16:31
Copilot AI lite review requested due to automatic review settings September 3, 2026 16:31
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@daxian-dbw Dongbo Wang (daxian-dbw) added the CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log label Sep 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changes are a straightforward replacement of a deprecated API with an already-used alternative in the repo, with no evident behavioral regressions for the DER certificate byte inputs in these call sites.

Pull request overview

This PR updates certificate loading paths to avoid the deprecated X509Certificate2(byte[]) constructor by using X509CertificateLoader.LoadCertificate, aligning PowerShell’s security-related code with current .NET guidance.

Changes:

  • Replace new X509Certificate2(byte[]) with X509CertificateLoader.LoadCertificate(byte[]) in CMS recipient resolution, serialization rehydration, and CIM conversion.
  • Remove the SYSLIB0057 suppression pragmas now that the deprecated constructor is no longer used.
  • Minor refactor/documentation: switch PEM/CMS sigil fields to const and add clarifying comments about the expected certificate encoding.
File summaries
File Description
src/System.Management.Automation/security/SecuritySupport.cs Loads DER certificate bytes via X509CertificateLoader during CMS recipient resolution; sigil fields changed to const and comments added.
src/System.Management.Automation/engine/serialization.cs Uses X509CertificateLoader.LoadCertificate when rehydrating X509Certificate2 from serialized RawData.
src/Microsoft.PowerShell.Commands.Management/cimSupport/cmdletization/cim/cimConverter.cs Uses X509CertificateLoader.LoadCertificate when converting CIM byte[] values into X509Certificate2.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@iSazonov

Copy link
Copy Markdown
Collaborator

I still see 16 SYSLIB0057 in the repo.

@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 0817ada into PowerShell:master Sep 22, 2026
44 of 47 checks passed
@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the msrc-serialization branch September 22, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Backport-7.7.x-Done CL-General Indicates that a PR should be marked as a general cmdlet change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants