Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Internet
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Colaboración Paypal con ClubDelphi

 
 
Herramientas Buscar en Tema Desplegado
  #11  
Antiguo 06-10-2021
espinete espinete is offline
Miembro
 
Registrado: mar 2009
Posts: 419
Poder: 17
espinete Va camino a la fama
Con AutoFirma consigo firmar el archivo, siguiendo los pasos que hay unos posts más atrás.

Con AutoFirma, el archivo firmado resultante ya está en UTF-8 SIN BOM sin tener que hacerle nada. AL parecer respeta la codificación original.
Además, según http://tools.chilkat.io/xmlDsigVerify.cshtml, esta vez obtengo 3 Digest válidos en el archivo firmado, no 2 como ocurría con SecureBlackBox.

No obstante, obtengo el mismo error al hacer el envío, por lo que creo que el problema no está en la firma.

Así que, o bien el proceso de envío hace algo raro al archivo, o yo ya no sé donde más mirar.

¿Hay alguna forma de saber si el envío (con NetHTTPClient1) está tocando algo en el archivo? ¿Hay alguna forma de saber realmente lo que está pasando?

Y yo que pensaba que la firma y envío de Bizkaia era problemático... No puede ser que lleve días con esto, y algo me dice que cuando descubra la causa del problema voy a salir de la oficina directo al bar.

El envío lo hago así:

RequestBody := TFileStream.Create('firmado.xml', fmOpenRead);

NetHTTPClient1.SecureProtocols := [THTTPSecureProtocol.TLS12];
NetHTTPClient1.CustomHeaders['Content-Type'] := 'application/xml';
NetHTTPClient1.CustomHeaders['Charset'] := 'UTF-8';

AResponse := NetHTTPClient1.Post('https://tbai-prep.egoitza.gipuzkoa.eus/WAS/HACI/HTBRecepcionFacturasWEB/rest/recepcionFacturas/alta',RequestBody);

Lo único que se me ocurre es que, como pasa con los Streams cuando se cargan, haya que hacer algún Position := 0 antes de enviarlo, pero eso no explica que "el archivo se ha modificado...", sino que daría otro error, digo yo, vamos.

Os pongo el archivo sin firmar y el firmado, obviando la info. sensible:

Factura SIN FIRMAR:

Código:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<T:TicketBai
	xmlns:T="urn:ticketbai:emision"
	xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd">
	<Cabecera>
		<IDVersionTBAI>1.2</IDVersionTBAI>
	</Cabecera>
	<Sujetos>
		<Emisor>
			<NIF>1111111H</NIF>
			<ApellidosNombreRazonSocial>Empresa Emisora</ApellidosNombreRazonSocial>
		</Emisor>
		<Destinatarios>
			<IDDestinatario>
				<NIF>00000000A</NIF>
				<ApellidosNombreRazonSocial>CLIENTE DE PRUEBAS</ApellidosNombreRazonSocial>
				<CodigoPostal>28080</CodigoPostal>
				<Direccion>Calle Madrid</Direccion>
			</IDDestinatario>
		</Destinatarios>
		<VariosDestinatarios>N</VariosDestinatarios>
		<EmitidaPorTercerosODestinatario>N</EmitidaPorTercerosODestinatario>
	</Sujetos>
	<Factura>
		<CabeceraFactura>
			<NumFactura>158</NumFactura>
			<FechaExpedicionFactura>04-10-2021</FechaExpedicionFactura>
			<HoraExpedicionFactura>10:38:20</HoraExpedicionFactura>
			<FacturaSimplificada>N</FacturaSimplificada>
			<FacturaEmitidaSustitucionSimplificada>N</FacturaEmitidaSustitucionSimplificada>
		</CabeceraFactura>
		<DatosFactura>
			<FechaOperacion>04-10-2021</FechaOperacion>
			<DescripcionFactura>Factura 158</DescripcionFactura>
			<DetallesFactura>
				<IDDetalleFactura>
					<DescripcionDetalle>Linea 1</DescripcionDetalle>
					<Cantidad>1</Cantidad>
					<ImporteUnitario>100</ImporteUnitario>
					<Descuento>0</Descuento>
					<ImporteTotal>121</ImporteTotal>
				</IDDetalleFactura>
			</DetallesFactura>
			<ImporteTotalFactura>150</ImporteTotalFactura>
			<RetencionSoportada>0</RetencionSoportada>
			<Claves>
				<IDClave>
					<ClaveRegimenIvaOpTrascendencia>01</ClaveRegimenIvaOpTrascendencia>
				</IDClave>
			</Claves>
		</DatosFactura>
		<TipoDesglose>
			<DesgloseFactura>
				<Sujeta>
					<NoExenta>
						<DetalleNoExenta>
							<TipoNoExenta>S1</TipoNoExenta>
							<DesgloseIVA>
								<DetalleIVA>
									<BaseImponible>50.00</BaseImponible>
									<TipoImpositivo>0</TipoImpositivo>
									<CuotaImpuesto>0.00</CuotaImpuesto>
									<TipoRecargoEquivalencia>0</TipoRecargoEquivalencia>
									<CuotaRecargoEquivalencia>0</CuotaRecargoEquivalencia>
									<OperacionEnRecargoDeEquivalenciaORegimenSimplificado>N</OperacionEnRecargoDeEquivalenciaORegimenSimplificado>
								</DetalleIVA>
							</DesgloseIVA>
						</DetalleNoExenta>
					</NoExenta>
				</Sujeta>
			</DesgloseFactura>
		</TipoDesglose>
	</Factura>
	<HuellaTBAI>
		<EncadenamientoFacturaAnterior>
			<SerieFacturaAnterior></SerieFacturaAnterior>
			<NumFacturaAnterior>157</NumFacturaAnterior>
			<FechaExpedicionFacturaAnterior>04-10-2021</FechaExpedicionFacturaAnterior>
			<SignatureValueFirmaFacturaAnterior>Rp9ubVl90QiCXICZOZ8l9OYAEm6Zy2T3hf2aE7+a0hHKf/6i8jADAr0vO9TyEdnVaI603OXYsHRYPhTEbLOL4jiERUon8G2pF/Fr</SignatureValueFirmaFacturaAnterior>
		</EncadenamientoFacturaAnterior>
		<Software>
			<LicenciaTBAI>TBAIGIPREXXXXXXXXXXX</LicenciaTBAI>
			<EntidadDesarrolladora>
				<NIF>11111111H</NIF>
			</EntidadDesarrolladora>
			<Nombre>Nombre Empresa Desarrolladora</Nombre>
			<Version>15.5</Version>
		</Software>
		<NumSerieDispositivo>NSERIEPC</NumSerieDispositivo>
	</HuellaTBAI>
</T:TicketBai>
Archivo FIRMADO:

Código:
<?xml version="1.0" standalone="no"?>
<T:TicketBai
	xmlns:T="urn:ticketbai:emision"
	xmlns:ds="http://www.w3.org/2000/09/xmldsig#"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/TR/xmldsig-core/xmldsig-core-schema.xsd">
	<Cabecera>
		<IDVersionTBAI>1.2</IDVersionTBAI>
	</Cabecera>
	<Sujetos>
		<Emisor>
			<NIF>11111111H</NIF>
			<ApellidosNombreRazonSocial>Empresa Emisora</ApellidosNombreRazonSocial>
		</Emisor>
		<Destinatarios>
			<IDDestinatario>
				<NIF>00000000A</NIF>
				<ApellidosNombreRazonSocial>CLIENTE DE PRUEBAS</ApellidosNombreRazonSocial>
				<CodigoPostal>28080</CodigoPostal>
				<Direccion>Calle Madrid</Direccion>
			</IDDestinatario>
		</Destinatarios>
		<VariosDestinatarios>N</VariosDestinatarios>
		<EmitidaPorTercerosODestinatario>N</EmitidaPorTercerosODestinatario>
	</Sujetos>
	<Factura>
		<CabeceraFactura>
			<NumFactura>127</NumFactura>
			<FechaExpedicionFactura>02-01-2021</FechaExpedicionFactura>
			<HoraExpedicionFactura>09:52:59</HoraExpedicionFactura>
			<FacturaSimplificada>N</FacturaSimplificada>
			<FacturaEmitidaSustitucionSimplificada>N</FacturaEmitidaSustitucionSimplificada>
		</CabeceraFactura>
		<DatosFactura>
			<FechaOperacion>02-01-2021</FechaOperacion>
			<DescripcionFactura>Factura 127</DescripcionFactura>
			<DetallesFactura>
				<IDDetalleFactura>
					<DescripcionDetalle>Linea 1</DescripcionDetalle>
					<Cantidad>1</Cantidad>
					<ImporteUnitario>100</ImporteUnitario>
					<Descuento>0</Descuento>
					<ImporteTotal>121</ImporteTotal>
				</IDDetalleFactura>
			</DetallesFactura>
			<ImporteTotalFactura>283</ImporteTotalFactura>
			<RetencionSoportada>0</RetencionSoportada>
			<Claves>
				<IDClave>
					<ClaveRegimenIvaOpTrascendencia>01</ClaveRegimenIvaOpTrascendencia>
				</IDClave>
			</Claves>
		</DatosFactura>
		<TipoDesglose>
			<DesgloseFactura>
				<Sujeta>
					<NoExenta>
						<DetalleNoExenta>
							<TipoNoExenta>S1</TipoNoExenta>
						</DetalleNoExenta>
					</NoExenta>
				</Sujeta>
			</DesgloseFactura>
		</TipoDesglose>
	</Factura>
	<HuellaTBAI>
		<Software>
			<LicenciaTBAI>TBAIGIPREXXXXXXXXXXX</LicenciaTBAI>
			<EntidadDesarrolladora>
				<NIF>11111111H</NIF>
			</EntidadDesarrolladora>
			<Nombre>Nombre Empresa Desarrolladora</Nombre>
			<Version>15.5</Version>
		</Software>
		<NumSerieDispositivo>NSERIEPC</NumSerieDispositivo>
	</HuellaTBAI>
	<ds:Signature
		xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-273182162">
		<ds:SignedInfo>
			<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
			<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
			<ds:Reference URI="">
				<ds:Transforms>
					<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
				</ds:Transforms>
				<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
				<ds:DigestValue>8rAQe4EJbS2Hbck2KibE6/DSQfnnUeUSV4wGd6ctHGo=</ds:DigestValue>
			</ds:Reference>
			<ds:Reference Type="http://uri.etsi.org/01903#SignedProperties" URI="#SignedProperties-353751308">
				<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
				<ds:DigestValue>y8Pk+uqYxel3FZNOZ3aAwWhc6v00vG0XLmOuzHYRh/w=</ds:DigestValue>
			</ds:Reference>
		</ds:SignedInfo>
		<ds:SignatureValue>VH0FvdPyHojub+GWvvUVrbs3jdgblZ/TcAzLhEw/nDTBK2mKyTzE7uEi6SPECk1DfhniUwWU66D8jVN59Pis3RyKN+3K6hEOPWU3amtETAu8jKYU13MMulJ6UMHL0ovSLS4ccGUdjmw6C2F7FgtCZqSlvUvhSOcH5BCFqzBzZ6b1LCoTPWCSnZ7pRQDcBOYc44zzmrfb4Wc3IjsC3EFNWydLUFcRJ7jCPVWG8+2r2vebg+EDZ7T+F1sK3+ti+mD65LxijQ==</ds:SignatureValue>
		<ds:KeyInfo>
			<ds:KeyValue>
				<ds:RSAKeyValue>
					<ds:Modulus>tk8wSaUTZz4q2pMW2dUJw42pq88hSzyBpdl9/F5topSDokrMrOkMx9de3nUAuyPt+KACXINBtZyDleqqgrcpo6kup+CAZQ576InVwDORZ5SXlYjVo7HpC3wX9puZmN9NaTfpX62Ie2gsie01zZaACL6n5q4k8cIpfwAh8XBPAmp/EsKLzZ+aPBbpBZ4ORolgkb/0e20wzO3qqiXXGb/ACLBcrKlyBCQbfbD0eONZc1xQSBw5RNioKlELJ8M+H1OzISJKunFqU2AE3vnXfRPfCEPLoSYhOEqJ/WU0DiQ==</ds:Modulus>
					<ds:Exponent>AQAB</ds:Exponent>
				</ds:RSAKeyValue>
			</ds:KeyValue>
			<ds:X509Data>
				<ds:X509IssuerSerial>
					<ds:X509IssuerName>CN=AC Representación, OU=CERES, O=FNMT-RCM, C=ES</ds:X509IssuerName>
					<ds:X509SerialNumber>109179261942007942106360154753800986544</ds:X509SerialNumber>
				</ds:X509IssuerSerial>
				<ds:X509SubjectName>#0C505265673A3338303133202F486F6A613A54462D3631383239202F546F6D6F3A33353934202F466F6C696F3A313639202F46656368613A31332F31312F32303138202F496E73637269706369C3B36E3A31</ds:X509SubjectName>
				<ds:X509Certificate>ACHxcE8Can8SwovNn5o8FukFng5GiWCRv/R7bTDM7eqqJdcZv8AIsFysqXIEJBt9sPR441lzXFBIHDlE2KgqUQsnwz4fU7MhIkq6cWpTYATe+dd9E98IQ8uhJiE4Son9ZTQOJAgMBAAGjggTnMIIE4zCCAQ0GA1UdEQSCAQQwggEAgRpURU5FUklGRUFTRVNPUkVTQEdNQUlMLkNPTaSB4TCB3jEjMCEGCSsGAQQBrGYBFAwUQWRtaW5pc3RyYWRvciDDum5pY28xHjAcBgkrBgEEAaxmAQcMD1ZBVEVTLUI3Njc4MDAyMjElMCMGCSsGAQQBrGYBBgwWU0lNUExZR0VTVCBTT0ZUV0FSRSB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BEU19lbi5wZGYTAmVuMAsGBgQAjkYBAwIBDzAfBgNVHSMEGDAWgBTcUJaf1zGJyRHk75Zf9l+CUkZiUzCB4QYDVR0fBIHZMIHWMIHToIHQoIHNhoGdbGRhcDovL2xkYXByZXAuY2VydC5mbm10LmVzL0NOPUNSTDEyMDcsT1U9QUMlMjBSZXByZXNlbnRhY2lvbixPVT1DRVJFUyxPPUZOTVQtUkNNLEM9RVM/Y2VydGlmaWNhdGVSZXZvY2F0aW9uTGlzdDtiaW5hcnk/YmFzZT9vYmplY3RjbGFzcz1jUkxEaXN0cmlidXRpb25Qb2ludIYraHR0cDovL3d3dy5jZXJ0LmZubXQuZXMvY3Jsc3JlcC9DUkwxMjA3LmNybDANBgkqhkiG9w0BAQsFAAOCAQEAkG4TGv/ArJrPNHQeXncVs/JOvudxvPcosE92KtgjyNMfOCsNShokvxst0SBl0zYmu+DMOhOuYInfTIy1Nty7uYLWYHfgDA3VIyhJ6WQjni4pkYz9e7pAcRhQ7xzZn7cHeN9w8a3TJBPOp5g/x9sxfmlmorbyR7EeSN7wGbpyQ7cAdnw0e6KGucCYSWMMz1NbH97w9LZEQ14eKfX3sfwMqYYODHrTxarR5kORW9mD+gvqUOn7GIPih6mpVRHeYiDK2cbhtYYMoD2yXxugcWQriZhdtgpIv+kHuCrOXGewzE7K38Cn9IuUs2TdIunaRO0gli3sQN+EijTejYpiqXV4RA==</ds:X509Certificate>
			</ds:X509Data>
		</ds:KeyInfo>
		<ds:Object>
			<xades:QualifyingProperties
				xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" Target="#Signature-273182162">
				<xades:SignedProperties Id="SignedProperties-353751308">
					<xades:SignedSignatureProperties>
						<xades:SigningTime>2021-10-06T18:27:18.930Z</xades:SigningTime>
						<xades:SigningCertificate>
							<xades:Cert>
								<xades:CertDigest>
									<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
									<ds:DigestValue>MLXj91aK6rK8d6lHMBs68CzzIhbGho9YNmPD0QpV4B4=</ds:DigestValue>
								</xades:CertDigest>
								<xades:IssuerSerial>
									<ds:X509IssuerName>CN=AC Representación, OU=CERES, O=FNMT-RCM, C=ES</ds:X509IssuerName>
									<ds:X509SerialNumber>109179261942007942106360154753800986544</ds:X509SerialNumber>
								</xades:IssuerSerial>
							</xades:Cert>
						</xades:SigningCertificate>
						<xades:SignaturePolicyIdentifier>
							<xades:SignaturePolicyId>
								<xades:SigPolicyId>
									<xades:Identifier>https://www.gipuzkoa.eus/ticketbai/sinadura</xades:Identifier>
								</xades:SigPolicyId>
								<xades:SigPolicyHash>
									<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
									<ds:DigestValue>6NrKAm60o7u62FUQwzZew24ra2ve9PRQYwC21AM6In0=</ds:DigestValue>
								</xades:SigPolicyHash>
								<xades:SigPolicyQualifiers>
									<xades:SigPolicyQualifier>
										<xades:SPURI>https://www.gipuzkoa.eus/ticketbai/sinadura</xades:SPURI>
									</xades:SigPolicyQualifier>
								</xades:SigPolicyQualifiers>
							</xades:SignaturePolicyId>
						</xades:SignaturePolicyIdentifier>
					</xades:SignedSignatureProperties>
				</xades:SignedProperties>
			</xades:QualifyingProperties>
		</ds:Object>
	</ds:Signature>
</T:TicketBai>
En el firmado he borrado algunos trozos de datos pero respetando todos los apartados, obviamente.

Espero de verdad que sirva de algo
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
SII -Nuevo sistema de la Agencia Tributaria española de envío de datos vía Webservice newtron Internet 3706 Hace 2 Semanas 09:38:43
Como utilizar la ayuda del nuevo Sistema Operativo gluglu Humor 3 24-09-2007 09:39:05
Aplicacion Agencia De Viajes ArdiIIa Varios 9 20-01-2007 16:49:53
El Vasco Aguirre Al González La Taberna 5 26-05-2006 09:22:28
Microsoft ha lanzado su nuevo sistema operativo DarkByte Humor 0 25-01-2004 09:21:14


La franja horaria es GMT +2. Ahora son las 13:27:26.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi