Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Failure reading private key file generated on Windows with CRLF line ending #104

Copy link
Copy link
@jeecha

Description

@jeecha
Issue body actions

Description
Library fails to read private key data from PKCS1 or PKCS8 file in PEM format that has been written on Windows with CRLF line endings. The code in https://github.com/Mastercard/client-encryption-java/blob/main/src/main/java/com/mastercard/developer/utils/EncryptionUtils.java#L66 does not strip all line ending characters, so Base64 decode will fail with an invalid character exception.
This happens because library first removes all LF (\n) and then tries to remove CRLF (\r\n), with the latter not doing anything because all LF characters have been already removed and CRLF has been reduced to just CR.

To Reproduce
Generate or save a private key PEM file on Windows machine using CRLF line endings.

Expected behavior
Library should be able to handle all line endings specified in RFC 7468 - https://www.rfc-editor.org/rfc/rfc7468#page-5 - CR, LF or CRLF.

Suggest a fix/enhancement
See https://github.com/Mastercard/client-encryption-java/blob/main/src/main/java/com/mastercard/developer/utils/EncryptionUtils.java#L66

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.