Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions lib/SecurityUtility.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,7 @@ public function generateSecurityToken($xmlDom, $certificateFilePath, $keyPass, &
// for PKCS12 files
openssl_pkcs12_read($certificate, $certs, $keyPass);
$privateKeyId = openssl_pkey_get_private($certs['pkey']);
$pubcert = explode("\n", $certs['cert']);
array_shift($pubcert);

while (!trim(array_pop($pubcert))) { /* Empty whlie loop */ }

array_walk($pubcert, 'trim');
$pubcert = implode('', $pubcert);
$pubcert = $certs['cert'];
unset($certs);
}
else
Expand All @@ -35,6 +29,16 @@ public function generateSecurityToken($xmlDom, $certificateFilePath, $keyPass, &
openssl_x509_export($tempcert, $pubcert);
}

// trim
$pubcert = explode("\n", $pubcert);
array_shift($pubcert);

while (!trim(array_pop($pubcert))) { /* Empty while loop */ }

array_walk($pubcert, 'trim');
$pubcert = implode('', $pubcert);


// add public key reference to the token
$tokenElement = $xmlDom->createElementNS(self::WSSE_NS, 'wsse:BinarySecurityToken', $pubcert);
$tokenElement->setAttribute('ValueType', 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3');
Expand Down