Skip to content

Commit

Permalink
Make inaccessable private key exception more informative
Browse files Browse the repository at this point in the history
Perviously setting $config['rsa_private_key'] = 'file://full/path/to/key.pem' (note two slashes instead of three) or other variations that are incompatitible with openssl_pkey_private(), would just give the user "Cannot access private key for signing", for a file that is very much accessable. The additional info I've added allows the user to go straight to the manual instead of spending time thinking it's a permissions issue.
  • Loading branch information
gerrywastaken committed Jun 29, 2015
1 parent 194068f commit bb23ade
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/XeroPHP/Remote/OAuth/SignatureMethod/RSASHA1.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ class RSASHA1 implements SignatureMethodInterface {

public static function generateSignature(array $config, $sbs, $secret) {
// Fetch the private key
if(false === $private_key_id = openssl_pkey_get_private($config['rsa_private_key']))
throw new Exception('Cannot access private key for signing');
if(false === $private_key_id = openssl_pkey_get_private($config['rsa_private_key'])){
throw new Exception("Cannot access private key for signing: openssl_pkey_get_private('${config['rsa_private_key']}') returned false");
}

// Sign using the key
if(false === openssl_sign($sbs, $signature, $private_key_id)) {
Expand Down

0 comments on commit bb23ade

Please sign in to comment.