Skip to content

Remove any combination of CR/LF line endings when reading private key#105

Merged
danny-gallagher merged 1 commit intoMastercard:mainfrom
jeecha:patch-1
Nov 28, 2024
Merged

Remove any combination of CR/LF line endings when reading private key#105
danny-gallagher merged 1 commit intoMastercard:mainfrom
jeecha:patch-1

Conversation

@jeecha
Copy link
Contributor

@jeecha jeecha commented Nov 26, 2024

Link to issue/feature request: #104

Description

RFC 7468 permits LF, CR or CRLF line endings in PEM files.

Current code first removes LF (\n) and then tries to remove CRLF (\r\n), so the CR (\n) characters are left in the file and key Base64 cannot be decoded. Because of this private key files generated/saved on Windows with CRLF line endings cannot be loaded into library.

The updated code handles CR and LF separately, so any combination of these characters will get removed from PEM data.

… from PEM

RFC 7468 permits LF, CR or CRLF line endings in PEM files.

Current code first removes LF (\n) and then tries to remove CRLF (\r\n), so the CR (\n) characters are left in the file and key Base64 cannot be decoded. Because of this private key files generated/saved on Windows with CRLF line endings cannot be loaded into library.
@danny-gallagher danny-gallagher added the safe The PR has been reviewed by Mastercard and has been validated to be safe label Nov 28, 2024
@danny-gallagher danny-gallagher self-requested a review November 28, 2024 11:23
@danny-gallagher
Copy link
Contributor

LGTM 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe The PR has been reviewed by Mastercard and has been validated to be safe

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants