Skip to content
Permalink
Browse files

changes the way to pass the private key (string or resource now)

In that way it is consistent to the passed passphrase option, which is a string or resource too.
  • Loading branch information...
TheFRedFox committed May 31, 2016
1 parent 1a2ccba commit 7fbb811f4ac0ee571f015b62954455f0696b59ba
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/Network/Http/Auth/Oauth.php
@@ -61,7 +61,7 @@ public function authentication(Request $request, array $credentials)
break;
case 'RSA-SHA1':
if (!isset($credentials['privateKeyFile'])) {
if (!isset($credentials['privateKey'])) {
return;
}
$value = $this->_rsaSha1($request, $credentials);
@@ -193,6 +193,13 @@ protected function _rsaSha1($request, $credentials)
$values['oauth_realm'] = $credentials['realm'];
}
if (is_resource($credentials['privateKey'])) {
$resource = $credentials['privateKey'];
$privateKey = stream_get_contents($resource);
rewind($resource);
$credentials['privateKey'] = $privateKey;
}
$credentials += [
'privateKeyPassphrase' => null,
];
@@ -202,7 +209,7 @@ protected function _rsaSha1($request, $credentials)
rewind($resource);
$credentials['privateKeyPassphrase'] = $passphrase;
}
$privateKey = openssl_pkey_get_private(file_get_contents($credentials['privateKeyFile']), $credentials['privateKeyPassphrase']);
$privateKey = openssl_pkey_get_private($credentials['privateKey'], $credentials['privateKeyPassphrase']);
$signature = '';
openssl_sign($baseString, $signature, $privateKey);
openssl_free_key($privateKey);

0 comments on commit 7fbb811

Please sign in to comment.
You can’t perform that action at this time.