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

"Invalid RSAES-OAEP padding" Error #76

Closed
petermikitsh opened this issue Feb 6, 2015 · 7 comments
Closed

"Invalid RSAES-OAEP padding" Error #76

petermikitsh opened this issue Feb 6, 2015 · 7 comments

Comments

@petermikitsh
Copy link

Here's my SAML Configuration:

var samlStrategy = new saml.Strategy({
    callbackUrl: 'https://myServer.rit.edu/login/callback',
    entryPoint: 'https://shibboleth.main.ad.rit.edu/idp/profile/SAML2/Redirect/SSO',
    issuer: 'https://myServer.rit.edu/shibboleth',
    identifierFormat: null,
    decryptionPvk: fs.readFileSync('/var/www/saml/key.pem', 'utf8'),
    cert: 'MIIDV......'
}, function(profile, done) {
    return done(null, profile);
});

Routes:

app.get('/',
  passport.authenticate('saml', {failureRedirect: '/login/fail'}),
  function(req, res) {
    res.send('Authenticated');
  }
);

app.post('/login/callback',
   passport.authenticate('saml', { failureRedirect: '/login/fail' }),
  function(req, res) {
    res.redirect('/');
  }
);

General error catcher:

app.use(function(err, req, res, next){
    console.log('Express error!');
    console.log("the error: " + JSON.stringify(err));
    next(err);
});

Shibboleth processes the request and a SAMLResponse is present in the header of callback route, /login/callback.

An error is thrown at passport.authenticate('saml', {failureRedirect: '/login/fail'}) in the / route.
Console log:

Express error!
the error: {"message":"Invalid RSAES-OAEP padding."}

Any ideas?

@ploer
Copy link
Contributor

ploer commented Feb 6, 2015

Well, this is the error message you receive when the encrypted assertion does not match the private key you have supplied. I.e., your shibboleth provider has a public key for you that does not match the decryptionPvk you are supplying.

Not sure if that is what you are seeing here, but the poor error message has bitten me several times in the past, I've been meaning to look into what we can do to give a better error here. (it is being passed up from the underlying xmlenc library, not something generated directly by passport-saml)

@petermikitsh
Copy link
Author

I've confirmed with my identity provider that the correct public key is on file.

@ploer
Copy link
Contributor

ploer commented Feb 6, 2015

Then the next debugging step that comes to mind would be to step into the xmlenc decrypt call (or add some debug logging), and check if everything looks correct in there.

It's definitely an error from the crypto layer, so if the right public key and private key are being used, I'd look at whether the private key is being loaded correctly, whether there is anything unusual about the format of those keys, etc.

@petermikitsh
Copy link
Author

You are correct.

The XML module (xml-encryption) passes the encrypted data and private key to the 'forge' package:
https://github.com/auth0/node-xml-encryption/blob/master/lib/xmlenc.js#L208

Where the error is eventually thrown here:
https://github.com/digitalbazaar/forge/blob/master/js/pkcs1.js#L254

I might try re-generating a new public/private key pair, and coordinating with the IdP. However, I don't know what else could be causing this, but it isn't your package.

@ploer ploer closed this as completed Feb 9, 2015
@petermikitsh
Copy link
Author

For anyone who comes across this, try regenerating your keys and certificate-- that was my issue. Also, try configuring with something like testshib.org (see #10) first before having to annoy your IdP Admin to reload your metadata frequently :)

@ploer
Copy link
Contributor

ploer commented Feb 26, 2015

I should put something about how useful testshib can be for debugging in the docs. I'll file a bug for that.

@ricardosaracino
Copy link

Can someone point me in the direction of how to add aes256-cbc Assertion encryption support... i see this lib but not sure how to put it all together

https://github.com/auth0/node-xml-encryption

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