GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Replace the deprecated `X509Certificate2` constructor with `X509CertificateLoader.LoadCertificate` by daxian-dbw · Pull Request #27965 · PowerShell/PowerShell

Conversation

@daxian-dbw

@daxian-dbw Dongbo Wang (daxian-dbw) commented Sep 3, 2026

Copy link
Copy Markdown
Member

PR Summary

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

PR Checklist

  • PR has a meaningful title
    • Use the present tense and imperative mood when describing your changes
  • Summarized changes
  • Make sure all .h, .cpp, .cs, .ps1 and .psm1 files have the correct copyright header
  • This PR is ready to merge. If this PR is a work in progress, please open this as a Draft Pull Request and mark it as Ready to Review when it is ready to merge.
  • Breaking changes
    • None
    • OR
    • Experimental feature(s) needed
      • Experimental feature name(s):
  • User-facing changes
    • Not Applicable
    • OR
    • Documentation needed
      • Issue filed:
  • Testing - New and feature
    • N/A or can only be tested interactively
    • OR
    • Make sure you've added a new test if existing tests do not effectively test the code changed

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@daxian-dbw
Replace the deprecated 'X509Certificate2' constructor with 'X509Certi…
d7cec4a
…ficateLoader.LoadCertificate'
@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

azure-pipelines Bot commented Sep 3, 2026

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Copilot started reviewing on behalf of Dongbo Wang (daxian-dbw) September 3, 2026 16:32
View session
@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 reviewed Sep 3, 2026
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
iSazonov
Ilya (iSazonov) approved these changes Sep 4, 2026
View reviewed changes
@iSazonov

Ilya (iSazonov) commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

I still see 16 SYSLIB0057 in the repo.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

SeeminglyScience
Patrick Meinecke (SeeminglyScience) approved these changes Sep 22, 2026
View reviewed changes
@daxian-dbw
Dongbo Wang (daxian-dbw) merged commit 0817ada into PowerShell:master Sep 22, 2026
44 of 47 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@daxian-dbw
Dongbo Wang (daxian-dbw) deleted the msrc-serialization branch September 22, 2026 19:36
@daxian-dbw Dongbo Wang (daxian-dbw) added the Backport-7.7.x-Consider label Sep 22, 2026
@daxian-dbw Dongbo Wang (daxian-dbw) added Backport-7.7.x-Done and removed Backport-7.7.x-Consider labels Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments
@iSazonov Ilya (iSazonov) iSazonov approved these changes
@SeeminglyScience Patrick Meinecke (SeeminglyScience) SeeminglyScience approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

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

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@daxian-dbw @iSazonov @SeeminglyScience
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.