Skip to content

Commit

Permalink
update samples to new x509cert
Browse files Browse the repository at this point in the history
  • Loading branch information
giansalex committed Feb 15, 2018
1 parent a5c2bed commit 254e293
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions CONVERT.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,33 @@
## Convert to .PEM
El archivo resultante se utiliza para firmar los comprobantes electrónicos.
```php
use Greenter\XMLSecLibs\Tool\PfxConverter;
use Greenter\XMLSecLibs\Certificate\X509Certificate;
use Greenter\XMLSecLibs\Certificate\X509ContentType;

require __DIR__.'/../vendor/autoload.php';

$pfx = file_get_contents('your-cert.pfx');
$password = 'YOUR-PASSWORD';

$converter = new PfxConverter($pfx, $password);
$pem = $converter
->toPem()
->getResult();
$certificate = new X509Certificate($pfx, $password);
$pem = $certificate->export(X509ContentType::PEM);

file_put_contents('certificate.pem', $pem);
```

### Convert a .CER
El archivo resultante se utiliza para subirlo a SUNAT.
```php
use Greenter\XMLSecLibs\Tool\PfxConverter;
use Greenter\XMLSecLibs\Certificate\X509Certificate;
use Greenter\XMLSecLibs\Certificate\X509ContentType;

require __DIR__.'/../vendor/autoload.php';

$pfx = file_get_contents('your-cert.pfx');
$password = 'YOUR-PASSWORD';

$converter = new PfxConverter($pfx, $password);
$cer = $converter
->toCer()
->getResult();
$certificate = new X509Certificate($pfx, $password);
$cer = $certificate->export(X509ContentType::CER);

file_put_contents('certificate.cer', $cer);
```

0 comments on commit 254e293

Please sign in to comment.