SSO internal error issue when connecting to Azure/ActiveDirectory

Your software
My Mautic version is: 5.0.1
My PHP version is: 8.1.26
My Database type and version is:

Your problem
My problem is:

We’ve followed the instructions within the documentation (https://docs.mautic.org/en/4.x/authentication/authentication.html) for setting up the SSO connect with active directory/azure but then encounter and internal 500 error.

These errors are showing in the log:

[2024-01-18 13:13:33] mautic.WARNING: PHP Warning - openssl_sign(): Supplied key param cannot be coerced into a private key - in file /home/mha-mauticstaging/htdocs/html/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php - at line 563 {“hostname”:“ip-172-31-32-133”,“pid”:849076}

[2024-01-18 13:13:33] mautic.CRITICAL: Uncaught PHP Exception Exception: “Failure Signing Data: error:1E08010C:DECODER routines::unsupported - SHA256” at /home/mha-mauticstaging/htdocs/html/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php line 564 {“exception”:“[object] (Exception(code: 0): Failure Signing Data: error:1E08010C:DECODER routines::unsupported - SHA256 at /home/mha-mauticstaging/htdocs/html/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php:564)”} {“hostname”:“ip-172-31-32-133”,“pid”:849076}

Steps I have tried to fix the problem:

  1. Cleared cache
  2. Created a new project within Azure, followed the SSO instructions again and ended with the same result.
  3. Created a new server instance, clean Mautic 4 and 5 install and immediate test of SSO following instructions from the documentation and same result

Update: Updated the platform to 5.0.3 php version 8.1.27 and updated the metadata.xml.

Now receiving an internal 500 error with the error log showing:

[2024-02-07T11:49:12.565895+00:00] mautic.CRITICAL: Uncaught PHP Exception ArgumentCountError: "LightSaml\SpBundle\Controller\DefaultController::__construct(): Argument #1 ($metadataProfileBuilder) not passed" at /home/mha-mauticstaging/htdocs/html/vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Controller/DefaultController.php line 29 {"exception":"[object] (ArgumentCountError(code: 0): LightSaml\\SpBundle\\Controller\\DefaultController::__construct(): Argument #1 ($metadataProfileBuilder) not passed at /home/mha-mauticstaging/htdocs/html/vendor/lightsaml/sp-bundle/src/LightSaml/SpBundle/Controller/DefaultController.php:29)"} {"hostname":"ip-172-31-32-133","pid":1384581}