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

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 12-04-2021
Avatar de Neftali [Germán.Estévez]
Neftali [Germán.Estévez] Neftali [Germán.Estévez] is offline
[becario]
 
Registrado: jul 2004
Ubicación: Barcelona - España
Posts: 18.325
Poder: 10
Neftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en brutoNeftali [Germán.Estévez] Es un diamante en bruto
Cita:
Empezado por benjy.sr Ver Mensaje
Pero siempre obtengo el mismo error:

Error receiving data: (12030) La conexión con el servidor finalizó anormalmente.

He desactivado firewall, por si acaso, pero siempre me devuelve lo mismo, seguro que hay que tener en cuenta algo que se me está escapando, ¿Alguien puede darme una idea de qué puede estar ocurriendo?

Parece que tiene que ver con el certificado (o relacionado con TSL).
Revisa los mensajes de esta página:
http://www.clubdelphi.com/foros/show...=94264&page=17
__________________
Germán Estévez => Web/Blog
Guía de estilo, Guía alternativa
Utiliza TAG's en tus mensajes.
Contactar con el Clubdelphi

P.D: Más tiempo dedicado a la pregunta=Mejores respuestas.
Responder Con Cita
  #2  
Antiguo 12-04-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Ejemplo (parte1)

Código Delphi [-]
var
success: Boolean;
xmlToSign: HCkXml;
gen: HCkXmlDSigGen;
object1: HCkXml;
cert: HCkCert;
sbXml: HCkStringBuilder;
verifier: HCkXmlDSig;
numSigs: Integer;
verifyIdx: Integer;
verified: Boolean;

begin
success := True;
//  Load the XML to be signed from a file...
xmlToSign := CkXml_Create();
CkXml_LoadXmlFile(xmlToSign,'xmlToSign.xml');

gen := CkXmlDSigGen_Create();

CkXmlDSigGen_putSigLocation(gen,'T:TicketBai');
CkXmlDSigGen_putSigLocationMod(gen,0);
CkXmlDSigGen_putSigId(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-Signature');
CkXmlDSigGen_putSigNamespacePrefix(gen,'ds');
CkXmlDSigGen_putSigNamespaceUri(gen,'h_t_t_p:w_w_w_.w3.org/2000/09/xmldsig#');
CkXmlDSigGen_putSigValueId(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignatureValue');
CkXmlDSigGen_putSignedInfoCanonAlg(gen,'C14N');
CkXmlDSigGen_putSignedInfoDigestMethod(gen,'sha256');
Responder Con Cita
  #3  
Antiguo 12-04-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Ejemplo (parte2)

Código Delphi [-]
//  Set the KeyInfoId before adding references..
CkXmlDSigGen_putKeyInfoId(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-KeyInfo');

//  Create an Object to be added to the Signature.
object1 := CkXml_Create();
CkXml_putTag(object1,'xades:QualifyingProperties');
CkXml_AddAttribute(object1,'xmlns:xades','h_t_t_p://uri.etsi.org/01903/v1.3.2#');
CkXml_AddAttribute(object1,'Id','Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-QualifyingProperties');
CkXml_AddAttribute(object1,'Target','#Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-Signature');
CkXml_AddAttribute(object1,'xmlns:ds','h_t_t_p://w_w_w.w3.org/2000/09/xmldsig#');
CkXml_UpdateAttrAt(object1,'xades:SignedProperties',True,'Id','Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignedProperties');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signi  ngTime','TO BE GENERATED BY CHILKAT');
CkXml_UpdateAttrAt(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCert  ificate|xades:Cert|xades:CertDigest|dsigestMethod',True,'Algorithm','h_t_t_p://w_w_w.w3.org/2001/04/xmlenc#sha512');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signi  ngCertificate|xades:Cert|xades:CertDigest|dsigestValue','TO BE GENERATED BY CHILKAT');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signi  ngCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName','TO BE GENERATED BY CHILKAT');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signi  ngCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber','TO BE GENERATED BY CHILKAT');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signa  turePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier','h_t_t_p_s://w_w_w.batuz.eus/fitxategiak/batuz/ticketbai/sinadura_elektronikoaren_zehaztapenak_especificaciones_de_la_firma_electronica_v1_0.pdf');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signa  turePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xadesescription','');
CkXml_UpdateAttrAt(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePo  licyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|dsigestMethod',True,'Algorithm','h_t_t_  p://w_w_w.w3.org/2001/04/xmlenc#sha256');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:Signa  turePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|dsigestValue','Quzn98x3PMbSHwbUza  j5f5KOpiH0u8bvmwbbbNkO9Es=');
Responder Con Cita
  #4  
Antiguo 12-04-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Ejemplo (parte3)

Código PHP:
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyQualifiers|xades:SigPolicyQualifier|xades:SPURI','h_t_t_p_s://w_w_w.batuz.eus/fitxategiak/batuz/ticketbai/sinadura_elektronikoaren_zehaztapenak_especificaciones_de_la_firma_electronica_v1_0.pdf');
CkXml_UpdateAttrAt(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat',True,'ObjectReference','#Reference-7e6f3481-4acc-47de-90fd-67878ad15e8e');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Description','');
CkXml_UpdateAttrAt(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:ObjectIdentifier|xades:Identifier',True,'Qualifier','OIDAsURN');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:ObjectIdentifier|xades:Identifier','urn:oid:1.2.840.10003.5.109.10');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:ObjectIdentifier|xades:Description','');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType','text/xml');
CkXml_UpdateChildContent(object1,'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Encoding','');

CkXmlDSigGen_AddObject(gen,'',CkXml__getXml(object1),'',''); 
Responder Con Cita
  #5  
Antiguo 12-04-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Ejemplo (parte4)

Código PHP:
//  -------- Reference 1 --------
CkXmlDSigGen_AddSameDocRef(gen,'','sha512','C14N','','h_t_t_p://w_w_w.w3.org/2000/09/xmldsig#Object');
CkXmlDSigGen_SetRefIdAttr(gen,'','Reference-7e6f3481-4acc-47de-90fd-67878ad15e8e');

//  -------- Reference 2 --------
CkXmlDSigGen_AddObjectRef(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignedProperties','sha512','','','h_t_t_p://uri.etsi.org/01903#SignedProperties');

//  -------- Reference 3 --------
CkXmlDSigGen_AddSameDocRef(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-KeyInfo','sha512','','','');

//  Load a certificate that has been pre-installed on the Windows system
//  This includes certificates on smartcards and USB tokens
cert := CkCert_Create();
success := CkCert_LoadByCommonName(cert,'The cert Subject CN');
if (
success <> Truethen
  begin
    Memo1
.Lines.Add(CkCert__lastErrorText(cert));
    Exit;
  
end;
CkXmlDSigGen_SetX509Cert(gen,cert,True);

CkXmlDSigGen_putKeyInfoType(gen,'X509Data+KeyValue');
CkXmlDSigGen_putX509Type(gen,'Certificate');

//  Load XML to be signed...
sbXml := CkStringBuilder_Create();
CkXml_GetXmlSb(xmlToSign,sbXml);

CkXmlDSigGen_putBehaviors(gen,'IndentedSignature,TransformSignatureXPath');

//  Sign the XML...
success := CkXmlDSigGen_CreateXmlDSigSb(gen,sbXml);
if (
success <> Truethen
  begin
    Memo1
.Lines.Add(CkXmlDSigGen__lastErrorText(gen));
    Exit;
  
end;
//  -----------------------------------------------

//  Save the signed XML to a file.
success := CkStringBuilder_WriteFile(sbXml,'qa_output\signedXml.xml','utf-8',False);

Memo1.Lines.Add(CkStringBuilder__getAsString(sbXml)); 
Responder Con Cita
  #6  
Antiguo 12-04-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
El ejemplo anterior crea una firma digital prácticamente idéntica a la original.
Para rizar el rizo se pueden generar dos UUID (los de 'signature' y 'reference') y modificar el código para que cada vez tenga unos UUID distintos
Responder Con Cita
  #7  
Antiguo 12-04-2021
Galaxian Galaxian is offline
Miembro
 
Registrado: mar 2021
Posts: 52
Poder: 4
Galaxian Va por buen camino
Para enviar (es código C++, que es el lenguaje que uso, aunque su traducción a Pascal/Delphi no el muy complicada porque la estructura es la misma, aunque su sintaxis difiera un poco:

Código PHP:
CkRest rest;
CkSocket socket;

success socket.SetSslClientCertPfx("d:\\xxx.pfx","xxxxxxxxxx");
if (
success != true) {std::cout << socket.lastErrorText() << "\r\n"; return;}

bool bTls true;
int port 443;
int maxWaitMs 5000;

success socket.Connect("pruesarrerak.bizkaia.eus",port,bTls,maxWaitMs);

if (
success != true
{
    
std::cout << "Connect Failure Error Code: " << socket.get_ConnectFailReason() << "\r\n";
    
std::cout << socket.lastErrorText() << "\r\n";
    return;
}

bool bAutoReconnect true;

// Use the connection:
success rest.UseConnection(socket,bAutoReconnect);
if (
success != true) {std::cout << rest.lastErrorText() << "\r\n"; return;}

CString jsn="{\"con\":\"LROE\",\"apa\":\"1.1\",\"inte\":{\"nif\":\"XXXXXXXXXX\",\"nrs\":\"XXXXXXXXXX\"},\"drs\":{\"mode\":\"140\",\"ejer\":\"2020\"}}";
cTexto dat=cFicheroBase::Leer("D:\\Ejemplo_LROE_140.xml").Texto();

rest.put_Utf8(SI);

rest.AddHeader("Accept-Encoding","gzip");
rest.AddHeader("Content-Encoding","gzip");
rest.AddHeader("Content-Type","application/octet-stream");
rest.AddHeader("eus-bizkaia-n3-version","1.0");
rest.AddHeader("eus-bizkaia-n3-content-type","application/xml");
rest.AddHeader("eus-bizkaia-n3-data",jsn);

int rst=rest.SendReqStringBody("POST","/N3B4000M/aurkezpena",dat);
rst=rest.ReadResponseHeader();
cchar *cr=rest.responseHeader();

CkByteData rb;
rst=rest.ReadRespBodyBinary(rb);
const 
uchar *dta=rb.getData();
int lng=rb.getSize();

cBinario rb2(dta,lng);
rb2=cCompresion::Descomprimir::Gzip(rb2);

return; 
Hay que tener en cuenta que la librería chilkat reconoce la cabecera 'Content-Encoding: gzip" y COMPRIME el envío y DESCOMPRIME la respuesta, que, a su vez, está comprimida, por lo que habrá que descomprimirla.

Los certificados no solo pueden cargarse de pfx, sino también del almacén de Windows o usar uno cargado anteriormente
Responder Con Cita
  #8  
Antiguo 09-12-2021
Kang Kang is offline
Registrado
 
Registrado: dic 2021
Posts: 1
Poder: 0
Kang Va por buen camino
Cita:
Empezado por Galaxian Ver Mensaje
Código Delphi [-]
var
success: Boolean;
xmlToSign: HCkXml;
gen: HCkXmlDSigGen;
object1: HCkXml;
cert: HCkCert;
sbXml: HCkStringBuilder;
verifier: HCkXmlDSig;
numSigs: Integer;
verifyIdx: Integer;
verified: Boolean;

begin
success := True;
//  Load the XML to be signed from a file...
xmlToSign := CkXml_Create();
CkXml_LoadXmlFile(xmlToSign,'xmlToSign.xml');

gen := CkXmlDSigGen_Create();

CkXmlDSigGen_putSigLocation(gen,'T:TicketBai');
CkXmlDSigGen_putSigLocationMod(gen,0);
CkXmlDSigGen_putSigId(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-Signature');
CkXmlDSigGen_putSigNamespacePrefix(gen,'ds');
CkXmlDSigGen_putSigNamespaceUri(gen,'h_t_t_p:w_w_w_.w3.org/2000/09/xmldsig#');
CkXmlDSigGen_putSigValueId(gen,'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignatureValue');
CkXmlDSigGen_putSignedInfoCanonAlg(gen,'C14N');
CkXmlDSigGen_putSignedInfoDigestMethod(gen,'sha256');

Utilicé el código anterior, pero no puedo completar la firma y no hay cambios en el archivo XML. ¿Hay algo que me haya perdido?
Responder Con Cita
  #9  
Antiguo 09-12-2021
YellowStone YellowStone is offline
Miembro
 
Registrado: feb 2007
Ubicación: Adeje
Posts: 35
Poder: 0
YellowStone Va por buen camino
Esta es una función que me he montado en una DLL externa para firmar los XML con las Chilkat, por si te sirve de ayuda. Me base en los posts de Galaxian, aunque haciendo ciertas modificaciones porque tampoco me iban, aparte de que hay que retocar direcciones por vienen, por ejemplo, con h_t_t_p y no http.

Código PHP:
function Firma_CLK(var HaciendaWideString; var PfxWideString; var PasswordWideString; var FicheroWideString): booleanstdcall;
var
  
xmlToSignHCkXml;
  
genHCkXmlDSigGen;
  
object1HCkXml;
  
certHCkCert;
  
sbXmlHCkStringBuilder;
begin

  
//  Load the XML to be signed from a file...
  
xmlToSign := CkXml_Create();
  try
    
CkXml_LoadXmlFile(xmlToSignPWideChar(Fichero));

    
gen := CkXmlDSigGen_Create();
    
CkXmlDSigGen_putBehaviors(gen'TransformSignatureXPath, LocalSigningTime, IndentedSignature'); // Añadido LocalSigningTime para que salga la hora como con Autofirma

    
CkXmlDSigGen_putSigLocation(gen'T:TicketBai');
    
CkXmlDSigGen_putSigLocationMod(gen0);
    
CkXmlDSigGen_putSigId(gen'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-Signature');
    
CkXmlDSigGen_putSigValueId(gen'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignatureValue');
    
CkXmlDSigGen_putSigNamespacePrefix(gen'ds');
    
CkXmlDSigGen_putSigNamespaceUri(gen'http://www.w3.org/2000/09/xmldsig#');  // Aquí faltaban las '//' despues de http:
    
CkXmlDSigGen_putSignedInfoCanonAlg(gen'C14N');
    
CkXmlDSigGen_putSignedInfoDigestMethod(gen'sha512'); // Cambiado a sha512, en el ejemplo viene sha256

    //  Set the KeyInfoId before adding references..
    
CkXmlDSigGen_putKeyInfoId(gen'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-KeyInfo');

    
//  Create an Object to be added to the Signature.
    
object1 := CkXml_Create();

    
CkXml_putTag(object1'xades:QualifyingProperties');
    
CkXml_AddAttribute(object1'Id''Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-QualifyingProperties');
    
CkXml_AddAttribute(object1'Target''#Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-Signature');
    
CkXml_AddAttribute(object1'xmlns:ds''http://www.w3.org/2000/09/xmldsig#');
    
CkXml_AddAttribute(object1'xmlns:xades''http://uri.etsi.org/01903/v1.3.2#');
    
CkXml_UpdateAttrAt(object1'xades:SignedProperties'True'Id''Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignedProperties');
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningTime''TO BE GENERATED BY CHILKAT');
    
CkXml_UpdateAttrAt(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestMethod'True'Algorithm','http://www.w3.org/2001/04/xmlenc#sha512');
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:CertDigest|ds:DigestValue''TO BE GENERATED BY CHILKAT');
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509IssuerName''TO BE GENERATED BY CHILKAT');
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SigningCertificate|xades:Cert|xades:IssuerSerial|ds:X509SerialNumber''TO BE GENERATED BY CHILKAT');

    
// Según la Hacienda Foral
    
if Hacienda '01' then // Araba
      
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier''https://ticketbai.araba.eus/tbai/sinadura/')
    else if 
Hacienda '20' then // Gipuzkoa
      
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier''https://www.gipuzkoa.eus/ticketbai/sinadura')
    else if 
Hacienda '48' then // Bizkaia
      
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Identifier''https://www.batuz.eus/fitxategiak/batuz/ticketbai/sinadura_elektronikoaren_zehaztapenak_especificaciones_de_la_firma_electronica_v1_0.pdf');

    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyId|xades:Description''');
    
CkXml_UpdateAttrAt(object1,'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestMethod',True,'Algorithm','http://www.w3.org/2001/04/xmlenc#sha256');

    
// Según la Hacienda Foral
    
if Hacienda '01' then // Araba
      
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue''iOgvkX7/yHIDRRiPy/LYQ0UUn7QV8/11D1BFbs8yMuQ=')
    else if 
Hacienda '20' then // Gipuzkoa
      
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue''6NrKAm60o7u62FUQwzZew24ra2ve9PRQYwC21AM6In0=')
    else if 
Hacienda '48' then // Bizkaia
      
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedSignatureProperties|xades:SignaturePolicyIdentifier|xades:SignaturePolicyId|xades:SigPolicyHash|ds:DigestValue''Quzn98x3PMbSHwbUzaj5f5KOpiH0u8bvmwbbbNkO9Es=');

    
CkXml_UpdateAttrAt(object1'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat'True'ObjectReference''#Reference-7e6f3481-4acc-47de-90fd-67878ad15e8e');
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Description''');
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:MimeType''application/octet-stream'); // Cambio a octet-stream como Autofirma
    
CkXml_UpdateChildContent(object1'xades:SignedProperties|xades:SignedDataObjectProperties|xades:DataObjectFormat|xades:Encoding''');

    
CkXmlDSigGen_AddObject(gen''CkXml__getXml(object1), '''');

    
//  -------- Reference 1 --------
    
CkXmlDSigGen_AddSameDocRef(gen'''sha512''C14N''''http://www.w3.org/2000/09/xmldsig#Object');
    
CkXmlDSigGen_SetRefIdAttr(gen'''Reference-7e6f3481-4acc-47de-90fd-67878ad15e8e');

    
//  -------- Reference 2 --------
    
CkXmlDSigGen_AddObjectRef(gen'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-SignedProperties''sha512''''''http://uri.etsi.org/01903#SignedProperties');

    
//  -------- Reference 3 --------
    
CkXmlDSigGen_AddSameDocRef(gen'Signature-63c35f38-2b5f-4600-b3da-3ddee86d62b3-KeyInfo''sha512' '''''');

    
//  Load a certificate that has been pre-installed on the Windows system
    //  This includes certificates on smartcards and USB tokens
    
cert := CkCert_Create();
    
result := CkCert_LoadPfxFile(certPWideChar(Pfx), PWideChar(Password));
    if (
not resultthen
      begin
        ShowMessage
('Fallo al cargar el certificado PFX: '+Pfx+' / '+Password);
        Exit;
      
end;

    
CkXmlDSigGen_SetX509Cert(gencertTrue);

    
// Cambiado Certificate a CertChain para que salgan todos los certificados incluidos,
    // porque en certificados como los de UANATACA se incluyen varios certificados en x509Certificate
    // y con Certificate sólo aparece el primero, que no tiene porque ser el que necesitamos
    
CkXmlDSigGen_putX509Type(gen,'CertChain');
    
CkXmlDSigGen_putKeyInfoType(gen,'X509Data+KeyValue');

    
//  Load XML to be signed...
    
sbXml := CkStringBuilder_Create();
    
CkXml_GetXmlSb(xmlToSignsbXml);

    
//  Sign the XML...
    
result := CkXmlDSigGen_CreateXmlDSigSb(gensbXml);

    if (
not resultthen
      begin
        ShowMessage
('Fallo en la firma');
        Exit;
      
end;

    
// Save the signed XML to a file.
    // Utilizo el mismo fichero de entrada
    // El último parámetro es False (no BOM o true BOM)
    
result := CkStringBuilder_WriteFile(sbXmlPWideChar(Fichero), 'utf-8'False);
  
except
    ShowMessage
('Error de excepcion');
    
result := False;
  
end;

end
Responder Con Cita
  #10  
Antiguo 09-12-2021
YellowStone YellowStone is offline
Miembro
 
Registrado: feb 2007
Ubicación: Adeje
Posts: 35
Poder: 0
YellowStone Va por buen camino
Aunque pone que es PHP, es Delphi; con el código DELPHI pone emoticonos en ciertas partes del código que lo hacen ilegible, y no permite más de 10 y no se puede subir.
Responder Con Cita
  #11  
Antiguo 09-12-2021
Ramon88 Ramon88 is offline
Miembro
 
Registrado: ago 2021
Posts: 125
Poder: 3
Ramon88 Va por buen camino
Pues parece que mi problema con Bizkaia es algo de ellos...


Esta fué su respuesta:
Estamos analizando qué ocurre con el certificado de autónomo e intentaremos responderle lo antes posible.

¿Puede utilizar por favor otro certificado para la realización de las pruebas?
Responder Con Cita
  #12  
Antiguo 09-12-2021
Ramon88 Ramon88 is offline
Miembro
 
Registrado: ago 2021
Posts: 125
Poder: 3
Ramon88 Va por buen camino
Una duda que tengo, cuando analizais el XML comaprado contra el esquema, lo haceis despues de firmarlo ?? si es así y hay un fallo, entiendo que no se puede subir, y que hay que paralizar la facturación o la subida de ficheros hasta que se subsane manualmente entiendo, el error en el xml ?
Responder Con Cita
  #13  
Antiguo 12-04-2021
benjy.sr benjy.sr is offline
Registrado
 
Registrado: nov 2007
Posts: 3
Poder: 0
benjy.sr Va por buen camino
No puedo conectar

Cita:
Empezado por Neftali [Germán.Estévez] Ver Mensaje
Parece que tiene que ver con el certificado (o relacionado con TSL).
Pues parece que si era por eso, muchas gracias Neftali.
Ahora me pide el certificado, pero la respuesta es vacía, revisando la respuesta el código es el 500, y el texto es "Internal server error",..... no sé qué puede ser

Última edición por Neftali [Germán.Estévez] fecha: 12-04-2021 a las 13:54:27. Razón: Corregir los TAGs
Responder Con Cita
  #14  
Antiguo 12-04-2021
Pau Haro Pau Haro is offline
Miembro
 
Registrado: mar 2021
Posts: 13
Poder: 0
Pau Haro Va por buen camino
Buenas,

Tengo problemas con el envio a Bizkaia, llega la solicitud al servidor pero la respuesta es incorrecta, por que el Id="xmldsig-bb95c614-22fb-4afe-9e6f-b46f4c46f971" no esta bien generado, esta cadena la genero usando el siguiente codigo en Java -> "xmldsig-" + UUID.randomUUID().toString();

Esto no esta funcionando y a diferencia de Guipuzkoa, Bizakaia no me retorna respuesta correcta por tener el ID mal. Estoy usando SecureBlackBox para realizar la firma de mi documento, si alguien me pudiera decir como generar el ID con SecureBackBox o con metodos nativos de Java, se lo agradeceria.

Saludos!
Responder Con Cita
Respuesta



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 3559 Hace 1 Día 20:02:30
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 07:40:00.


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