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

Public key construction creates alerts #152

Open
pr0x1ma-byte opened this issue Mar 20, 2024 · 1 comment
Open

Public key construction creates alerts #152

pr0x1ma-byte opened this issue Mar 20, 2024 · 1 comment

Comments

@pr0x1ma-byte
Copy link

I receive the following error when constructing a public key from an exponent and modulus:

ignoring stale global SSL error (SSL: error:0407008A:rsa routines:RSA_padding_check_PKCS1_type_1:invalid padding error:04067072:rsa routines:rsa_ossl_public_decrypt:padding check failed)

This is how I'm constructing the key:

local key, err = pkey.new(json_text, {format = "JWK"})
...
local pem, err = key:to_PEM("public",false)

After a bit I get an alert in my nginx log with the error from above.

@fffonion
Copy link
Owner

Hi @pr0x1ma-byte the alert log you are seeing indicating there's a uncleared error when doing pubkey:decrypt, but I don't seem to reproduce this using the following code:

local jwk = require("cjson").encode({
    kty = "RSA",
    n   = "pjdss8ZaDfEH6K6U7GeW2nxDqR4IP049fk1fK0lndimbMMVBdPv_hSpm8T8EtBDxrUdi1OHZfMhUixGaut-3nQ4GG9nM249oxhCtxqqNvEXrmQRGqczyLxuh-fKn9Fg--hS9UpazHpfVAFnB5aCfXoNhPuI8oByyFKMKaOVgHNqP5NBEqabiLftZD3W_lsFCPGuzr4Vp0YS7zS2hDYScC2oOMu4rGU1LcMZf39p3153Cq7bS2Xh6Y-vw5pwzFYZdjQxDn8x8BG3fJ6j8TGLXQsbKH1218_HcUJRvMwdpbUQG5nvA2GXVqLqdwp054Lzk9_B_f1lVrmOKuHjTNHq48w",
    e   = "AQAB",
})
local key = assert(require("resty.openssl.pkey").new(jwk, {format = "JWK"}))
local err = require("resty.openssl.err")
print(err.format_error("x"))

print(key:decrypt("x"))
local pem = assert(key:to_PEM("public",false))
print(err.format_error("x"))

could you share more about the code that you use that involves pubkey decrypt operations?

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