-
Notifications
You must be signed in to change notification settings - Fork 89
Description
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