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

Generate Invalid RSA PEM Format #628

Open
emn178 opened this issue Aug 15, 2024 · 0 comments
Open

Generate Invalid RSA PEM Format #628

emn178 opened this issue Aug 15, 2024 · 0 comments

Comments

@emn178
Copy link

emn178 commented Aug 15, 2024

Following code:

var kp = KEYUTIL.generateKeypair('RSA', 1024);
privateKey = KEYUTIL.getPEM(kp.prvKeyObj, 'PKCS5PRV', '12345678', 'AES-256-CBC');

Sometimes it has a blank line before -----END RSA PRIVATE KEY-----, for example

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-256-CBC,A441CCFC835FD714E8573D9ED0701F76

oFE+zAOFpbY4fdfZsZ8wxhsgoxkRWwlCLzavjOZTjBGGKNypzYMiinK0fyIt1Q0A
HVoNLm81A7/2kAwrcex3L/iimBZoAYFjBMu+FC0+L3UbegKJVUXhQe2nenz8tpeI
SwsBtRvAnbraPfYfL6xFUgyALH7+pYyinr0oQJ0Bvye+0tVKTJ0mgYIxOqakpL7p
P7gcoC89Lifqrr0oNfVKYxI8R7hLgPUGGY7NYMy/NHkJY06dDPWMTY43nrykZ3+m
rdFJk/cwCWS84QwkZPLdEGog7FPTwLFJmjwnt2UnlICr7xb6PinUad74OoincRHf
5SBRxU7a56E7LHHgFJefxaORXBMym0EXw9+GzBmAu/hKblTkZImRgg+LS6NXvRBV
6X8KLp2s05/OylYMF4u9i/wL2SfT3soycbwx8hMsJK3aaLyUr0rOFmqWNcJ8bozw
YTbwWAatTkJkzaXvhZNFFzmLv6ppoZMTt8VhLXHbuJ+7b9FYOgYgZZmoudqUlrNO
RJPcONqkY0kWKUaCfbOViyhue9BTiQ6uqqaf7xgriAUn1h1SGs+1BetAPrrgdmV6
GQAHev882AuSE39bTb5f2wc1UQFHiOXvI+n/P0bWpWMPy28ydRDeK7IabXXeVjid
ODKPWhJpm90xbmOTDsrJ+y/8v/P0Rp66k8OpzeF76cH7bKQWvCShlxqyk/NIJCb1
S0lQxMSnPU7w9GgPx90NZR57L/wqd7PMt3EJjlpEzfm2jJZnu3n+aH8Pxlny6reG
/uODpwU8KLBu/RBj0MrYksGvUKmDHdi7jcI7BHCGE0NQul8XK36zyL9Efqgu4IG0

-----END RSA PRIVATE KEY-----

When you use it in openssl, it will return error

$ openssl rsa -in priv-key.pem -pubout > pub-key.pem
unable to load Private Key
8525234496:error:0908F066:PEM routines:get_header_and_data:bad end line:crypto/pem/pem_lib.c:841:
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

1 participant