Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for CRLF when parsing RSA PEM keys #38

Merged
merged 2 commits into from
Apr 28, 2019

Conversation

wederchr
Copy link
Contributor

@wederchr wederchr commented Apr 26, 2019

Fixes #36

@@ -64,8 +64,7 @@ class RSAKeyParser {
return _parsePrivate(_pkcs8PrivateSequence(_parseSequence(rows)));
}

// NOTE: Should we throw an exception?
return null;
throw ArgumentError('Unable to parse key, invalid format.');
Copy link
Owner

Choose a reason for hiding this comment

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

I left this note for further discussion.
Why do you think we should throw an exception?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the methods taking the parsed key as an argument will most likely throw an exception if the key is null. Fail-fast would be better in this case.

Copy link
Owner

Choose a reason for hiding this comment

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

Do you agree that a FormatException is better is this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, absolutely. Will fix it right away.

@leocavalcante leocavalcante merged commit 42b21f3 into leocavalcante:master Apr 28, 2019
@leocavalcante
Copy link
Owner

Awesome, thank you!

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.

RSAKeyParser returns null when key uses CRLF line endings
2 participants