Skip to content

Attempting to Sign a AuthnRequest I Always Receive a Fatal Error #90

@TheWitness

Description

@TheWitness

I'm trying to use the method on the main website to sign a AuthNRequest to the IDP, but I'm always receiving the following error.

Fatal error: Uncaught Exception: Failure Signing Data: error:0480006C:PEM routines::no start line - 1 in /var/www/html/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php:564 
Stack trace: 
#0 /var/www/html/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php(644): RobRichards\XMLSecLibs\XMLSecurityKey->signOpenSSL('<ds:SignedInfo ...') 
#1 /var/www/html/vendor/robrichards/xmlseclibs/src/XMLSecurityDSig.php(832): RobRichards\XMLSecLibs\XMLSecurityKey->signData('<ds:SignedInfo ...') 
#2 /var/www/html/vendor/robrichards/xmlseclibs/src/XMLSecurityDSig.php(856): RobRichards\XMLSecLibs\XMLSecurityDSig->signData(Object(RobRichards\XMLSecLibs\XMLSecurityKey), '<ds:SignedInfo ...') 
#3 /var/www/html/vendor/litesaml/lightsaml/src/Model/XmlDSig/SignatureWriter.php(162): RobRichards\XMLSecLibs\XMLSecurityDSig->sign(Object(RobRichards\XMLSecLibs\XMLSecurityKey)) 
#4 /var/www/html/vendor/litesaml/lightsaml/src/Model/AbstractSamlModel.php(47): LightSaml\Model\XmlDSig\SignatureWriter->serialize(Object(DOMElement), Object(LightSaml\Model\Context\SerializationContext)) 
#5 /var/www/html/vendor/litesaml/lightsaml/src/Model/AbstractSamlModel.php(67): LightSaml\Model\AbstractSamlModel->oneElementToXml('Signature', Object(DOMElement), Object(LightSaml\Model\Context\SerializationContext), NULL) 
#6 /var/www/html/vendor/litesaml/lightsaml/src/Model/Protocol/AuthnRequest.php(297): LightSaml\Model\AbstractSamlModel->singleElementsToXml(Array, Object(DOMElement), Object(LightSaml\Model\Context\SerializationContext)) 
#7 /var/www/html/login_saml.php(65): LightSaml\Model\Protocol\AuthnRequest->serialize(Object(DOMDocument), Object(LightSaml\Model\Context\SerializationContext)) 
#8 {main} thrown in /var/www/html/vendor/robrichards/xmlseclibs/src/XMLSecurityKey.php on line 564

I'm using the example here:

<?php
$authnRequest = new \LightSaml\Model\Protocol\AuthnRequest();
$authnRequest
    ->setAssertionConsumerServiceURL('https://my.site/acs')
    ->setProtocolBinding(\LightSaml\SamlConstants::BINDING_SAML2_HTTP_POST)
    ->setID(\LightSaml\Helper::generateID())
    ->setIssueInstant(new \DateTime())
    ->setDestination('https://idp.com/login')
    ->setIssuer(new \LightSaml\Model\Assertion\Issuer('https://my.entity.id'))
;

$certificate = \LightSaml\Credential\X509Certificate::fromFile('certificate.crt');
$privateKey = \LightSaml\Credential\KeyHelper::createPrivateKey('private.key', '', true);

$authnRequest->setSignature(new \LightSaml\Model\XmlDSig\SignatureWriter($certificate, $privateKey));

$serializationContext = new \LightSaml\Model\Context\SerializationContext();
$authnRequest->serialize($serializationContext->getDocument(), $serializationContext);

It's got me scratching my head again.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions