thegreenter / xmldsig Goto Github PK
View Code? Open in Web Editor NEWFirma digital en Facturación Electrónica
License: BSD 3-Clause "New" or "Revised" License
Firma digital en Facturación Electrónica
License: BSD 3-Clause "New" or "Revised" License
Alguna idea porque lo coloca 3 veces ?
Hola, estoy intentando firmar un xml con un certificado pem que tiene una clave privada, hasta donde he podido ver en la clase XMLSecurityKey se declara una variable publica como:
$passphrase = "";
Después de buscar un rato no he encontrado ningún setter para esta variable, la cosa es que necesito indicar el passphrase para poder firmar el documento ya que si no la función openssl_get_privatekey( ) (ubicada en la línea 345 del archivo XMLSecurityKey.php) me devuelve un false al pasarse la variable
$this->passphrase.
Toda ayuda es bienvenida.
Gracias!
Hola amigo estoy tratando de usar tu librería cifrando con un archivo de extension .p12
$fileXmlName = "/path/file/factura.xml";
$docXmlExport = $rootNode->asXML($fileXmlName);
$docXml = $rootNode->asXML();
$certPath ="/path/file/key_example.p12";
$signer = new SignedXml();
$signer->setCertificateFromFile($certPath);
$xmlSigned = $signer->signFromFile($fileXmlName);
echo $xmlSigned;
al final me sale esta notificacion :
Warning: openssl_sign(): supplied key param cannot be coerced into a private key
Pdrias ayudarme o indicarme que estoy haciendo mal??
saludos
Buenas noches. Por favor me podria ayudar con este error. gracias.
Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\vendor\greenter\xmldsig\src\Sunat\firm5.php on line 5
Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\vendor\greenter\xmldsig\src\Sunat\firm5.php on line 5
I'm doing the example of the README.md and at the moment of executing the method signFromFile returns a null value and does not sign the xml
this my code:
use Greenter\XMLSecLibs\Sunat\SignedXml;
require 'vendor/autoload.php';
$xmlPath = '20516109549-01-F001-70.xml';
$certPath = 'certificate.pem'; // Convertir pfx to pem
$signer = new SignedXml();
$signer->setCertificateFromFile($certPath);
$xmlSigned = $signer->signFromFile($xmlPath);
var_dump($xmlSigned);
namespace App\Controllers\Sunat;
use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Greenter\XMLSecLibs\Certificate\X509Certificate;
use Greenter\XMLSecLibs\Certificate\X509ContentType;
use App\Controllers\NsAppController;
class NsCertificadoController extends NsAppController
{
public function pem(Request $request,Response $response){
$pfx = file_get_contents(_APP_CDN_PATH.'/NUEVOeG9yVURJN3NOU3ZjQktQZQ==.pfx');
$password = 'pA2kG9VVYn4M7GNE';
$certificate = new X509Certificate($pfx,$password);
$pem = $certificate->export(X509ContentType::PEM);
file_put_contents(_APP_CDN_PATH.'/certificate.pem', $pem);
return _APP_WSCDN.'/certificate.pem';
}
public function cer(Request $request,Response $response){
$pfx = file_get_contents(_APP_CDN_PATH.'/NUEVOeG9yVURJN3NOU3ZjQktQZQ==.pfx');
$password = 'pA2kG9VVYn4M7GNE';
$certificate = new X509Certificate($pfx,$password);
$cer = $certificate->export(X509ContentType::CER);
file_put_contents(_APP_CDN_PATH.'/certificate.cer', $cer);
return _APP_WSCDN.'/certificate.cer';
}
}
Me devuelve esto alguna idea???
Type: Exception
Message: error:23076071:PKCS12 routines:PKCS12_parse:mac verify failure
File: /AppServer/vendor/greenter/xmldsig/src/Certificate/X509Certificate.php
Line: 184
Trace: #0 /AppServer/vendor/greenter/xmldsig/src/Certificate/X509Certificate.php(42): Greenter\XMLSecLibs\Certificate\X509Certificate->parsePfx('0\x82,\x05\x02\x01\x030\x82+\xCB\x06\t*\x86...', 'pB2kG9VVYn4M7GN...')
#1 /AppServer/app/app/Controllers/Sunat/NsCertificadoController.php(38): Greenter\XMLSecLibs\Certificate\X509Certificate->__construct('0\x82,\x05\x02\x01\x030\x82+\xCB\x06\t*\x86...', 'pB2kG9VVYn4M7GN...')
#2 [internal function]: App\Controllers\Sunat\NsCertificadoController->cer(Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#3 /AppServer/vendor/slim/slim/Slim/Handlers/Strategies/RequestResponse.php(41): call_user_func(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#4 /AppServer/vendor/slim/slim/Slim/Route.php(356): Slim\Handlers\Strategies\RequestResponse->__invoke(Array, Object(Slim\Http\Request), Object(Slim\Http\Response), Array)
#5 /AppServer/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\Route->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#6 /AppServer/vendor/slim/slim/Slim/Route.php(334): Slim\Route->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#7 /AppServer/vendor/slim/slim/Slim/App.php(515): Slim\Route->run(Object(Slim\Http\Request), Object(Slim\Http\Response))
#8 /AppServer/vendor/slim/slim/Slim/MiddlewareAwareTrait.php(117): Slim\App->__invoke(Object(Slim\Http\Request), Object(Slim\Http\Response))
#9 /AppServer/vendor/slim/slim/Slim/App.php(406): Slim\App->callMiddlewareStack(Object(Slim\Http\Request), Object(Slim\Http\Response))
#10 /AppServer/vendor/slim/slim/Slim/App.php(314): Slim\App->process(Object(Slim\Http\Request), Object(Slim\Http\Response))
#11 /AppServer/public/app/index.php(10): Slim\App->run()
#12 {main}
amigo no encuentro la falla me aparece este error:
Fatal error: Uncaught Exception: error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error in C:\xampp\htdocs\xmldsig-master\src\Certificate\X509Certificate.php:184 Stack trace: #0 C:\xampp\htdocs\xmldsig-master\src\Certificate\X509Certificate.php(42): Greenter\XMLSecLibs\Certificate\X509Certificate->parsePfx('-----BEGIN CERT...', 'EQ4qpJKSWGmnbFd...') #1 C:\xampp\htdocs\xmldsig-master\index.php(10): Greenter\XMLSecLibs\Certificate\X509Certificate->__construct('-----BEGIN CERT...', 'EQ4qpJKSWGmnbFd...') #2 {main} thrown in C:\xampp\htdocs\xmldsig-master\src\Certificate\X509Certificate.php on line 184
Then functions getValidFrom() and getExpiration() in class x509Certificate.php seems to have returned values switched. getValidFrom() returns validTo_time_t and getExpiration() returns validFrom_time_t.
getValueFrom() should return value for validFrom_time_t
.
Buenas consulta como puedo cambiar la posición del Signature es decir si le paso mi xml siempre me pone al final del todo.
Pero quiero que me coloque después de otra etiqueta que esta aproximadamente a la mitad del xml.
Como se puede remover esto ? estuve mirando y hay un template, pero lo quito y aun asi los sigue coloando
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.