Skip to content

Permit \r, \n, \t and space after PEM encapsulation boundary in PrivateKeyPattern#1804

Draft
Copilot wants to merge 3 commits into
developfrom
copilot/fix-threading-issue-in-channel
Draft

Permit \r, \n, \t and space after PEM encapsulation boundary in PrivateKeyPattern#1804
Copilot wants to merge 3 commits into
developfrom
copilot/fix-threading-issue-in-channel

Conversation

Copilot AI commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

PEM keys injected via CI/CD environment variables (e.g. Azure DevOps) have their newlines replaced by spaces, producing a single-line key that the existing PrivateKeyPattern regex rejected.

Changes

  • PrivateKeyPattern regex: replaced all \r?\n with [\r\n\t ]+, accepting any mix of CR, LF, tab, or space as line separators throughout the PEM block — after -----BEGIN...-----, between header fields (Proc-Type, DEK-Info, Comment), between base64 data lines, and before -----END...-----. Convert.FromBase64String already ignores whitespace so the captured data group decodes correctly regardless.
  • Removed: InlinePemPattern, InlinePemRegex, NormalizePemText, and the two-pass fallback in Open — the updated regex handles inline keys directly on the first match attempt.

A key like the following now parses successfully:

-----BEGIN RSA PRIVATE KEY----- MIIEoQIBAAKCAQEA... QLTuX2Hj...JA== -----END RSA PRIVATE KEY-----

Copilot AI changed the title Support inline PEM private keys where newlines were replaced by spaces (CI/CD injection) Support inline PEM private keys (newlines replaced by spaces by CI/CD injection) Jun 13, 2026
Copilot AI requested a review from Rob-Hague June 13, 2026 15:37
Copilot AI changed the title Support inline PEM private keys (newlines replaced by spaces by CI/CD injection) Permit \r, \n, \t and space after PEM encapsulation boundary in PrivateKeyPattern Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants