<?php
$pfx = file_get_contents($file);
if (!openssl_pkcs12_read($pfx, $result, $password)) {
throw new \Exception('Não foi possível ler o certificado .pfx');
}
You should just be able to set it directly on the key.
$key->key = $privkey
For the cert, you use openssl_x509_export on the resource to get it into a compatible format to add to the signature
I have the certificate in OpenSSL format, how do I inject it
$signcert = {resource} resource id='15' type='OpenSSL X.509' $privkey = {resource} resource id='16' type='OpenSSL key'
<?php $pfx = file_get_contents($file); if (!openssl_pkcs12_read($pfx, $result, $password)) { throw new \Exception('Não foi possível ler o certificado .pfx'); }
$signcert = openssl_x509_read($file); $privkey = openssl_pkey_get_private($result['pkey'], $password);
$sig = new XMLSecurityDSig(); $key = new XMLSecurityKey(XMLSecurityKey::RSA_SHA1, array('type' => 'private'));
$key->loadKey($privkey, false, true); $sig->add509Cert($signcert );