Skip to content

Conversation

@vcsjones
Copy link
Member

Older Windows, namely Windows 8.1 and below, use RC2-40 when encrypting certificates in PKCS#12, so we cannot rely on the export being 3DES. This changes the export to re-encode if 3DES was explicitly asked for.

Copilot AI review requested due to automatic review settings February 21, 2025 23:28
@ghost ghost added the area-System.Security label Feb 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

PR Overview

This pull request refactors the PKCS#12 export logic to ensure that when 3DES is explicitly requested on older versions of Windows, the exported certificate is properly re‐encoded.

  • Introduces a new helper method ExportPkcs12Core that consolidates export and re‐encoding logic.
  • Adjusts the export paths for both AES and 3DES formats based on platform capabilities.

Reviewed Changes

File Description
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Windows.Export.cs Refactored the export routines to call ExportPkcs12Core, simplifying the logic for handling both AES and 3DES re-encoding.

Copilot reviewed 1 out of 1 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/StorePal.Windows.Export.cs:102

  • [nitpick] Consider renaming ExportPkcs12Core to a more descriptive name (e.g. ExportAndReencodePkcs12) to clearly indicate its dual role in exporting and conditionally re-encoding PKCS#12 data.
private unsafe byte[] ExportPkcs12Core(Pkcs12ExportPbeParameters? exportParameters, SafePasswordHandle password)

Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more

@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

@vcsjones vcsjones merged commit 4112020 into dotnet:main Feb 22, 2025
81 of 84 checks passed
@vcsjones vcsjones deleted the fix-obs-windows-pkcs12export branch February 22, 2025 13:29
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants