Ver Mensaje Individual
  #565  
Antiguo 05-05-2021
bilbur bilbur is offline
Miembro
 
Registrado: dic 2019
Posts: 60
Reputación: 5
bilbur Va por buen camino
Cita:
Empezado por Edgar7 Ver Mensaje
Lo primero de todo, ...

Signature is Invalid
Number of Reference Digests = 3
Reference 1 digest is invalid because the computed digest differs from the digest in the XML.
Reference 2 digest is invalid because the computed digest differs from the digest in the XML.
Reference 3 digest is valid.

¿Podrías confirmarme si el código que tienes puesto te genera correctamente la firma o decirme si te ha pasado algo similar?

Muchas gracias.

El código me funciona

Versión PHP 5.6.40
Has de ser muy estricto en el xml con el orden de las "references" y con los "digest"


Reference 1:

Código PHP:
        '<ds:Reference URI="#'.$this->SignedProperties.'" Type="http://uri.etsi.org/01903#SignedProperties">' .
        
'<ds:Transforms>' .
        
'<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>' .
        
'</ds:Transforms>' .        
        
'<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>' .
        
'<ds:DigestValue>'.$propDigest.'</ds:DigestValue>' .
        
'</ds:Reference>' 
Verás en el firmador:

Código PHP:
 $aconop     str_replace('<xades:SignedProperties''<xades:SignedProperties ' $xmnls_signedprops$prop);
    
$propDigest $this->retC14DigestSha1($aconop); 
Que llama a, también dentro del firmador:


Código PHP:
   public function retC14DigestSha1($strcadena)
    {
    
$strcadena    str_replace("\r"""str_replace("\n"""$strcadena));
    
$d1p        = new DOMDocument('1.0''UTF-8');
    
$d1p->loadXML($strcadena);
    
$strdata    $d1p->C14N();
    return 
base64_encode(hash('sha256' $strdatatrue ));
    } 
Ve despacio, prueba con la reference 1 y me dices
Si no avanzas, puedes hacerme llegar, no sé como, un xml de prueba firmado



Un saludo
Responder Con Cita