-
Notifications
You must be signed in to change notification settings - Fork 376
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
Error with method sign for String #171
Comments
Can you please provide example code? It looks like the RSA key is no present. |
The code is simply, pem = '-----BEGIN RSA PRIVATE KEY----- MIKCAQEAiqv0K2dMkuLyuZQiw4j8r7VQjP3zS+nUDgu80tfYA3usRGxx G8DmQDBWIi6MOj80K7nm0f+QcVaztN6NVgw07XaEg8sJ Yg16qULCO4nUhWcVnOaA1YdUC6bZ/DcA pfzPCDEpXT6Nwbj5uJs .... ----- END RSA PRIVATE KEY -----' JWT.encode( params, pem, 'RS256') And this give me the error, look like String class not have sign method |
I've discovered the error, key should be a OpenSSL::PKey::RSA instance. Sorry for inconvenences. |
Okay. But I think to improve the experience working with ruby jwt a better error should be displayed. "The given key is a #{private_key.class}. It has to be an OpenSSL::PKey::RSA instance." |
…_error Add user friendly encode error if private key is a String, #171
The error is:
undefined method `sign' for #String:0x00000002fbbb78
In line:
def sign_rsa(algorithm, msg, private_key)
private_key.sign(OpenSSL::Digest.new(algorithm.sub('RS', 'sha')), msg)
end
In file: jwt.rb 35
String class (private_key) not have sign method.
What is the problem?
The text was updated successfully, but these errors were encountered: