Skip to content

Commit

Permalink
Merge pull request #3 from alexminza/master
Browse files Browse the repository at this point in the history
Private key passphrase
  • Loading branch information
ruscon authored Nov 7, 2017
2 parents 9fa7101 + c912e2d commit dfc63b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/VictoriaBank/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ abstract class Request implements RequestInterface
* @var string
*/
static public $privateKeyPath;

/**
* Private key passphrase
* @var string
*/
static public $privateKeyPass;

/**
* @var bool
Expand Down Expand Up @@ -147,7 +153,7 @@ protected function _createSignature($order, $nonce, $timestamp, $trType, $amount
'TRTYPE' => $trType,
'AMOUNT' => VictoriaBankGateway::normalizeAmount($amount),
];
if (!$rsaKeyResource = openssl_get_privatekey($rsaKey)) {
if (!$rsaKeyResource = openssl_get_privatekey($rsaKey, self::$privateKeyPass)) {
die ('Failed get private key');
}
$rsaKeyDetails = openssl_pkey_get_details($rsaKeyResource);
Expand Down
3 changes: 2 additions & 1 deletion src/VictoriaBankGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,14 +328,15 @@ public function setMerchantUrl($url)
return $this;
}

public function setSecurityOptions($signatureFirst, $signaturePrefix, $signaturePadding, $publicKeyPath, $privateKeyPath, $bankPublicKeyPath)
public function setSecurityOptions($signatureFirst, $signaturePrefix, $signaturePadding, $publicKeyPath, $privateKeyPath, $bankPublicKeyPath, $privateKeyPass='')
{
#Request security options
VictoriaBank\Request::$signatureFirst = $signatureFirst;
VictoriaBank\Request::$signaturePrefix = $signaturePrefix;
VictoriaBank\Request::$signaturePadding = $signaturePadding;
VictoriaBank\Request::$publicKeyPath = $publicKeyPath;
VictoriaBank\Request::$privateKeyPath = $privateKeyPath;
VictoriaBank\Request::$privateKeyPass = $privateKeyPass;
#Response security options
VictoriaBank\Response::$signaturePrefix = $signaturePrefix;
VictoriaBank\Response::$bankPublicKeyPath = $bankPublicKeyPath;
Expand Down

0 comments on commit dfc63b8

Please sign in to comment.