Ver Mensaje Individual
  #14  
Antiguo 14-01-2025
razorxxx razorxxx is offline
Miembro
 
Registrado: jul 2015
Posts: 198
Reputación: 11
razorxxx Va por buen camino
Cita:
Empezado por delphiGar Ver Mensaje
Para la politica de firmas debes tener esto en el signature:

Código:
<ds:Object>
<xades:QualifyingProperties xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="#Signature-356076609">
<xades:SignedProperties Id="SignedProperties-896717916">
<xades:SignedSignatureProperties>
<xades:SigningTime>2025-01-09T09:06:03.661Z</xades:SigningTime>
<xades:SigningCertificate>
<xades:Cert>
<xades:CertDigest>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>GonBTW0Kj+S7ul49CizLsozDclU28uKhzNqqIGHkuRs=</ds:DigestValue>
</xades:CertDigest>
<xades:IssuerSerial>
<ds:X509IssuerName>CN=AC Representación, OU=CERES, O=FNMT-RCM, C=ES</ds:X509IssuerName>
<ds:X509SerialNumber>60125478927655539147584317276501208423</ds:X509SerialNumber>
</xades:IssuerSerial>
</xades:Cert>
</xades:SigningCertificate>
<xades:SignaturePolicyIdentifier>
<xades:SignaturePolicyId>
<xades:SigPolicyId>
<xades:Identifier>urn:oid:2.16.724.1.3.1.1.2.1.9</xades:Identifier>
</xades:SigPolicyId>
<xades:SigPolicyHash>
<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<ds:DigestValue>G7roucf600+f03r/o0bAOQ6WAs0=</ds:DigestValue>
</xades:SigPolicyHash>
<xades:SigPolicyQualifiers>
<xades:SigPolicyQualifier>
<xades:SPURI>https://sede.administracion.gob.es/politica_de_firma_anexo_1.pdf</xades:SPURI>
</xades:SigPolicyQualifier>
</xades:SigPolicyQualifiers>
</xades:SignaturePolicyId>
</xades:SignaturePolicyIdentifier>
</xades:SignedSignatureProperties>
<xades:SignedDataObjectProperties>
<xades:DataObjectFormat ObjectReference="#xmldsig-5cf63553-8a48-4ceb-83f8-861d341a4d67-ref0">
<xades:ObjectIdentifier>
<xades:Identifier>urn:oid:1.2.840.10003.5.109.10</xades:Identifier>
</xades:ObjectIdentifier>
<xades:MimeType>text/xml</xades:MimeType>
<xades:Encoding>UTF8</xades:Encoding>
</xades:DataObjectFormat>
</xades:SignedDataObjectProperties>
</xades:SignedProperties>
</xades:QualifyingProperties>
</ds:Object>
El algoritmo http://www.w3.org/2000/09/xmldsig#sha1 que sugieres no está soportado por las especificaciones de la firma que exige el reglamento, debe ser http://www.w3.org/2001/04/xmlenc#sha256.

El caso es que mandándole a mano al AutoFirma el DigestValue que aparece en el fichero de ejemplo firmado de la AEAT, me firma el archivo correctamente pero al validarlo en valide.redsara.es me devuelve el siguiente error: "El hash de la política incluido en la firma no coincide con el hash real de la política de firma".

La llamada que realizo es: AutoFirmaCommandLine.exe sign -i "ejemplo.xml" -o "ejemplo_signed.xml" -format xades -config "format=XAdES Enveloped \nincludeOnlySignningCertificate=true \npolicyIdentifier=urnid:2.16.724.1.3.1.1.2.1.9 \npolicyIdentifierHash=Dkx2R3nMv8kWo7iSAh+/1SQ70hfseOEaQbpJnURk+pg= \npolicyIdentifierHashAlgorithm=http://www.w3.org/2001/04/xmlenc#sha256 \npolicyQualifier=https://sede.administracion.gob.es/politica_de_firma_anexo_1.pdf" -store pkcs12:"cert.pfx" -password XXXX -filter subject.contains:89890001K

Está todo bien salvo el tema del hash de la política de firma. Otra cosa que intenté fue calcularlo desde archivo PDF: THashSHA2.GetHashStringFromFile('politica_de_firma_anexo_1.pdf'). Pero el error devuelto es el mismo.

¿Alguna idea de cómo solucionarlo?
Responder Con Cita