Unable to retrieve decryption key while decryt saml assertion - itfoxtec-identity-saml2

We are using itfox library for creating saml response. Assertion is encrypted successfully with relying party public key certificate. But on decryting saml assertion with relying party private key certificate, getting below error
Unable to retrieve decryption key while decryt saml assertion.

First, the DecryptionCertificate is added in the Saml2Configuration and it is required that the certificate have a private RSA key.
Maybe the problem is that the process hosting the ITfoxtec Identity SAML library do not have access to the certificates private key? If the certificate is installed in Windows certificate store on a server the process needs to be given access to the private key. Also, if deployed in an Azure App Service access to the certificate is configured.

Related

Is SP signing certificate mandatory in setting up trust

I have a basic question on setting up trust between a SP and IDP.
Usually a two way trust is required when we setup an IDP with SP by uploading certificates on either side.
Is signing certificate from SP mandatory to be configured in the IDP side ?
Best Regards,
Saurav
You only need a signing keypair on the SP side if you send the subject in the AuthnRequest, and your IdP utilizes the information when provided. If your SP isn't sending the subject attribute or your IdP won't consume it, you don't need it.
The defined SAML 2.0 specifications doesn't mandate that the request is signed.
4.1.3.3 <AuthnRequest> Is Issued by Service Provider to Identity Provider
...The <AuthnRequest> message MAY be signed, if authentication of the request issuer is required.
You can check with your Identity Provider documentation, but for example, Microsoft Azure AD does not validate signed requests, and there's no way to upload a request signing certificate.

SAML private and public key sharing

Our client (the IDP) has requested our private key so that they can register our service as an SP, which seems like a very strange request to me since giving them our private key gives them the ability to decrypt any of our other clients SAML requests and even create requests and attack other IdP's we're connected to.
I shut this down immediately but they then had me refer to Azure AD B2C documentation
To build a trust relationship between your service provider and Azure AD B2C, you need to provide X509 certificates and their private keys.
Is this normal? I've been under the assumption that they only need our x509 certificate
From the documentation it seems that your private key always stays with you:
Certificate with a private key stored in your Web App
the private key resides in the SP application (the web app that provides the SP functionality) and is used to sign a SAML Request to the IdP. The IdP only needs the SP's public key certificate from the SP's metadata in order to validate the signature.
(Optional) Certificate with a private key stored in your Web App
this is optional for the IdP to encrypt the SAML Response using the SP's public key certificate from the SP's metadata. The SP then uses its private key to decrypt the response.
The wording isn't great as it seems to say to hand over both the public and private keys to the IdP. That's not how SAML works though. It makes much more sense when read as 'hand over the public key and keep the corresponding private key in your SP webapp'.
I can't see any reason why an entity must divulge its private key to anything.

Why Keystore is needed when using SSO (SAMLv2)

I use Okta as my IDP and I have 2 use cases:
IDP-initiated SSO
when a user wants to login using his okta credentials to my system, I redirect him to okta, and okta send the response to a callback in my app.
I was wondering why I need the keystore? how is it used?
The messages to the IDP from the SP (my app) will be encrypted using this keystore key-pair? And if so, doesn't that mean that I need to somehow share my keys with okta?
I couldn't find any explanation on this.
Appritiate any help on this!
Thanks!
SAML Responses sent from a SAML Identity Provider ("IdP") like Okta will be signed using Okta's private key, these messages will be validated by a SAML Service Provider ("SP") like your application using the corresponding public key.
In your case, the keystore should only be used for Okta's public key (or public keys, if you federate with more than one Okta org). You will not need to share any keys with Okta, but you will need to get the public key from Okta somehow. The best way to get the public key from Okta would be via an IdP metadata URL, the next best way would be to have the Okta administrator paste Okta's X.509 encoded public key into your app somehow.

Why do I need to share the certificate with an SP for SSO when the certificate is included in the signed SAML response?

I am just wondering while implementing SAML SSO with Salesforce I realize that I uploaded the certificate to the SP side (i.e. Salesforce), however I can see when we send a signed SAML response it already includes the certificate.
Why is the certificate shared ahead of time with the SP?
It's all about establishing trust between systems. If you don't give SFDC your cert ahead of time, how can they trust the message you are sending is actually from your IDP? Without your cert ahead of time, they can validate that the message is intact but not who actually generated it. When you include your public key in the SAML Response, they can check that it's the same one you shared with them and it's the same one you used to generate the signature.

Signature Invalid/Configured Certificate Mismatch for SSO with SFDC

I did SSO of OpenAM and SalesForce.com (SFDC)
I have installed OpenAM-Client SDK to retrieve SAML Assertion from OpenAM.
I used this assertion data to generate SAML response required for SalesForce. When I pass this data to SFDC. I got error message for SAML.
“Failed: Signature Invalid/Configured Certificate Mismatch”
I used same certificate and signature data which I got from OpenAM-client SDK public API assertion.
At time of SSO configuration with SDFC. I used default certificate (test cert) provided by OpenAM.
Is there any way to retrieve test certificate and its signature from OpenAM ?
Run one of the failing SAML assertions through the SAML Validation tool inside Single Sign-On Settings in SFDC; you should get a slightly more useful error. The most likely cause of this is that you have not uploaded the correct certificate to SFDC as part of your SSO setup. Make sure the "Identity Provider Certificate" section of "Single Sign-On Settings" matches the cert contained in the assertion.

Resources