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

fromBase64 won't deal with \r\n correctly #362

Closed
deskangel opened this issue Jul 21, 2023 · 5 comments
Closed

fromBase64 won't deal with \r\n correctly #362

deskangel opened this issue Jul 21, 2023 · 5 comments
Milestone

Comments

@deskangel
Copy link

image

As shown in the above figure (where _len is 1588 and i - start is 1589), if the length of a base64-encoded key is not a multiple of 4 (does not end with the '=' symbol), fromBase64 cannot determine the correct length of the buffer (as a '\r' character is counted), resulting in an exception being thrown by fromBase64.

Removing these characters from the fromBase64 method may be a safer approach.

sample key:

-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA2Pt9umdG1Dp/JGFHN/fT9pq+xIdBOzXPcz67/NAdOcpH5rAjNOd0ohmEIMD+Wgc2ZPNz3VnWCCtdlPXjuVs08E9qaPT62U9AL7ARp1OzJM0kpV1+/XvRC2xmDVleA2n0/1R8VcArqHLRu1ylKKxgN2R8Rm4TVsqP/uizcMgjHMX6Y6QnpSVp+DE8BarNA1ZnuEdksvi2lYNzb+VW24tu3CGwPujq4rdmow1FAhyb3EJaRqzOsfcNM27eKVCOshzwhyCKmRD849dvORghemUM4tEzBH+MB7QPHzdV4J9bwcPiBJKwAJ0FHk1jkdZ3OggxRBk5cmJSLs+t+COAcH4QZQIDAQABAoIBAGcA5AuEEWyYJFkZ0Nwxyq6LgTn8VywLfGJiCo2WIfmYHA/X1666nXSCFmYSF+yW9exwYbVXezI/m9ol7CfGs1fM61/Nw/M7GuZId+jt4+H5fIb/3lPo3jDFEaEOpoGKYCKBcdCnPFJnx0ZhUYoAYmCJVDF++bE+0aKZxu0oJPr35Lda1hBeCfrb8fDReAAU71jIoOGyuSyOXlCVyT+OmBhVme0u2xDpdY8cd5t9YueTK7BFNjNt3sJOI4L+2wRskNwxqHCrECtuOXmzEyza7vqo8cjRGSx1HZfqhoKgiRpRkRmSi8p+X1+DZOVZuCxc3BTZ7WrPgVZhu7u9hsISKyECgYEA+C9ajUNsx7Hx9gOg6Zvr+zV461PjKI/0n9g0DTZ5RHdcAfeNs3ugmsiDK6b9SayUW08EVyveJ1OJjT/NPvdP0/KhCAjUt+kN0j9f9CPdHKEWoboDca8u67dayOAhC10mNhoAp3tFQryfgpb678GIzqnXkVjGgyWC/8Z81AN7uAkCgYEA39CcJAUVMc6FigTwoMOkdOgNK6qCxAxkNBTdfB/cBBtG3h8g49n0u/fAMjkfL6awdl53j3jVCP4pUZgSSqArLb0aGo84G2vP92iN3d3j/kPiox22w8KG2XR7tHLWcc+CFfk8mdiKdPFxaWVQaYJ6htGq9LGqY3sw5lVzmk0wlH0CgYEAuWim/WGhoo4NdPzA+cTCRqlr7GJ/EY558fBS8ov/jGafFdkawztYgEnLtJDMKH4FVzFwzK65CCggWqWPb7rSqERaiOYQBFTXPnqZ9InWZczyW1/bstJs+yu/ZtIJ3bN5GHHUi0pMM882Wxjv3q12xu2bXbo0k0Uy2GIwXzM6+gECgYBDByur0eXeC7aMdhxGWTEoXdKL8D3HTtq3ikQmhzgR9sVLglEMS9rybCkgIWFImQgh+vqdehd64Pso130q4jrsMMTfjWLFO42Fz8ck2e4M2PHH3f89M0XFXBAsI3Q7k2SnBgRzIpmcmi5X3SKu5oehVqt3KroXnu4vHQpI/LL+1QKBgD3zxf795zFXw53iZXtKkzYNQhEMVRzbx6dQE+tguB0YCb2vPvYaxfejg/02hCQ4twIMuMK18v0Y9W7E34C0m++lP8UbnHdR0Dsg9ryH7OlUMp4662060HWDnDy79swB/Nnk9dxf+BoPIXGny84bEpk6cLoiHuL6TRpQhuJ292DW
-----END RSA PRIVATE KEY-----
@norrisjeremy
Copy link
Contributor

Hi @deskangel,

We fixed handling of private key files that contain \r\n line endings as part of #266 in the 0.2.7 release.
Can you please update to our most recent release (0.2.9) and confirm if the issue you are having still occurs?

Thanks,
Jeremy

@norrisjeremy
Copy link
Contributor

Hi @deskangel,

We fixed handling of private key files that contain \r\n line endings as part of #266 in the 0.2.7 release. Can you please update to our most recent release (0.2.9) and confirm if the issue you are having still occurs?

Thanks,Jeremy
Jeremy

Hi @deskangel,

Disregard, I better understand now the issue you are having.

Thanks,
Jeremy

@norrisjeremy
Copy link
Contributor

Hi @deskangel,

Can you test with the JSch jar produced by Github CI from my #363 located here and confirm if it fixes the issue you are seeing with PEM type SSH private key files that contain \r\n type line endings?

Thanks,
Jeremy

@deskangel
Copy link
Author

Hi @norrisjeremy
I tested the jar file and it worked perfectly.

Thank you so much for taking the time to address the issue and for your hard work on it.

@norrisjeremy
Copy link
Contributor

Hi @deskangel,

Great, thanks for confirming!

Thanks,
Jeremy

@mwiede mwiede added this to the 0.2.10 milestone Jul 27, 2023
@mwiede mwiede closed this as completed Jul 27, 2023
norrisjeremy added a commit to norrisjeremy/jsch that referenced this issue Aug 1, 2023
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

No branches or pull requests

3 participants