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

EC256 Private Key Issue #2

Open
doodi-v1 opened this issue Aug 18, 2020 · 4 comments
Open

EC256 Private Key Issue #2

doodi-v1 opened this issue Aug 18, 2020 · 4 comments

Comments

@doodi-v1
Copy link

doodi-v1 commented Aug 18, 2020

I'm encountering an "Invalid PEM key." error while attempting to encode a token. What is strange is that when I walk through the code withing the parsePEMEncodedKey() function, the if( find( '-----BEGIN PRIVATE KEY-----', pemKey ) ) is triggered, the RSA block throws an exception and is caught as intended, but when the EC block is executed, it seems to throw a silent exception. I updated the catch to rethrow, and nothing is triggered but the return instruction is not executed, so I am assuming a silent exception.

Have you seen this behavior before?

I was able to port a bouncy castle pem reader example to CF. I then passed the private key to encode and public key to decode and it worked. The pem reader code I ported was from: https://connect2id.com/products/nimbus-jose-jwt/openssl-key-generation

@jcberquist
Copy link
Owner

I am not sure what is up. How did you generate your key? I presume you encoded your key in pkcs8 format? Also, could you tell me which version of ACF/Lucee are you on?

@doodi-v1
Copy link
Author

CF-2016. Key generation was openssl via similar instruction to your read.me: https://developers.google.com/pay/api/web/guides/resources/payment-data-cryptography#using-openssl

@jcberquist
Copy link
Owner

Ok, so to be clear, after you run:

openssl ecparam -name prime256v1 -genkey -noout -out key.pem

you should run:

openssl pkcs8 -topk8 -nocrypt -in key.pem -out key.pk8

The output of this second command (the .pk8 extension is not required) is the format of the key that is needed to use with this library. Is that what you did?

@doodi-v1
Copy link
Author

doodi-v1 commented Aug 20, 2020 via email

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

2 participants