# Receive encrypted SAML authentication assertions - Decode error

**URL:** <https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202>\
**Category:** Get Help\
**Tags:** connections, saml-enterprise-connection\
**Created:** [November 10, 2022, 6:43pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202 "2022-11-10T18:43:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleksandar.pavlovic](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/aleksandar.pavlovic/32/41207_2.png) [@aleksandar.pavlovic](https://community.auth0.com/u/aleksandar.pavlovic)\
**Post date:** [November 10, 2022, 6:43pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/1 "2022-11-10T18:43:47Z")

</div>

I’m using Auth0 as a SAML service provider. My connections to the external IDPs work when SAML assertions are not encrypted. When I turn on encryption on the external IDP and upload the certificate obtained from https://my\_auth0\_domain/cer?cert=my-connection I’am getting the following error:

`error:04099079:rsa routines:RSA_padding_check_PKCS1_OAEP_mgf1:oaep decoding error`

I tried with uploading different encryption certificate file formats, but that didn’t help.  
I didn’t set any custom decryptionKey, I am using the one provided by Auth0 by default.

---

<div class="post-metadata">

**Author:** ![aleksandar.pavlovic](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/aleksandar.pavlovic/32/41207_2.png) [@aleksandar.pavlovic](https://community.auth0.com/u/aleksandar.pavlovic)\
**Post date:** [November 17, 2022, 12:27am UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/2 "2022-11-17T00:27:24Z")

</div>

Solution:  
Don’t upload to IDP encryption certificate obtained from https://my\_auth0\_domain/cer?cert=my-connection

Use https://my\_auth0\_domain/samlp/metadata?connection=my-connection to fetch the Auth0 SP metadata. Then extract encryption certificate from downloaded metadata XML and manually create .cer or .pem file for uploading on the IDP side.

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [November 21, 2022, 2:16pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/3 "2022-11-21T14:16:37Z")

</div>

Thank you a lot for sharing it with the rest of community!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [December 5, 2022, 2:16pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/4 "2022-12-05T14:16:48Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [January 9, 2023, 6:09pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/5 "2023-01-09T18:09:03Z")

</div>



---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [January 9, 2023, 6:15pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/6 "2023-01-09T18:15:24Z")

</div>

A quick follow-up on this thread: if you request the certificate from `https://{your_auth0_domain}/pem?cert=connection`, you will obtain the same signing/encryption certificate that you would obtain from the SAML connection metadata(\*). It’s important that the query string has `cert=connection`, with the parameter value being the literal `connection` string value, not the connection name. I.e., don’t replace `connection`.

(\*) as long as the connection doesn’t have a custom key pair configured for either signing or encryption as described in [Use a custom key to sign requests](https://auth0.com/docs/authenticate/protocols/saml/saml-sso-integrations/sign-and-encrypt-saml-requests#use-your-key-pair-to-decrypt-encrypted-responses) and [Use your key pair to decrypt encrypted responses](https://auth0.com/docs/authenticate/protocols/saml/saml-sso-integrations/sign-and-encrypt-saml-requests#use-your-key-pair-to-decrypt-encrypted-responses).

---

<div class="post-metadata">

**Author:** ![nicolas\_sabena](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nicolas_sabena/32/6064_2.png) [@nicolas\_sabena](https://community.auth0.com/u/nicolas_sabena)\
**Post date:** [January 9, 2023, 6:30pm UTC](https://community.auth0.com/t/receive-encrypted-saml-authentication-assertions-decode-error/94202/7 "2023-01-09T18:30:24Z")

</div>


