Skip to content

Commit bf97330

Browse files
committed
comments resolved
1 parent 201dbdd commit bf97330

File tree

5 files changed

+25
-25
lines changed

5 files changed

+25
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"firebase/php-jwt": "^6.0.0",
2222
"monolog/monolog": ">=1.25.0",
2323
"web-token/jwt-framework": "^2.2.11|^3.3.5",
24-
"singpolyma/openpgp-php": "0.6.0"
24+
"singpolyma/openpgp-php": "0.5.0"
2525
},
2626
"require-dev": {
2727
"phpunit/phpunit": "9.6.15"

lib/Api/BatchUploadApi.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function __construct($logConfig = null)
4949
/**
5050
* Uploads a batch file using mutual TLS authentication with a PKCS#12 (.p12/.pfx) client certificate file.
5151
*
52-
* @param string $inputFile Path to the file to be uploaded.
52+
* @param string $inputFilePath Path to the file to be uploaded.
5353
* @param string $environmentHostname The environment hostname.
5454
* @param string $pgpEncryptionCertPath Path to the PGP encryption certificate.
5555
* @param string $clientCertP12FilePath Path to the PKCS#12 client certificate file (.p12 or .pfx).
@@ -60,7 +60,7 @@ public function __construct($logConfig = null)
6060
* @throws ApiException
6161
*/
6262
public function uploadBatchWithP12(
63-
$inputFile,
63+
$inputFilePath,
6464
$environmentHostname,
6565
$pgpEncryptionCertPath,
6666
$clientCertP12FilePath,
@@ -69,20 +69,20 @@ public function uploadBatchWithP12(
6969
$verify_ssl = true
7070
) {
7171
if (self::$logger) {
72-
self::$logger->info("Starting batch upload with P12/PFX for file: $inputFile");
72+
self::$logger->info("Starting batch upload with P12/PFX for file: $inputFilePath");
7373
if ($verify_ssl === false) {
7474
self::$logger->warning("SSL verification is DISABLED for this batch upload. This is insecure and should not be used in production.");
7575
}
7676
}
7777
BatchuploadUtility::validateBatchApiP12Inputs(
78-
$inputFile, $environmentHostname, $pgpEncryptionCertPath, $clientCertP12FilePath, $serverTrustCertPath
78+
$inputFilePath, $environmentHostname, $pgpEncryptionCertPath, $clientCertP12FilePath, $serverTrustCertPath
7979
);
8080

8181
$endpointUrl = $this->getEndpointUrl($environmentHostname, "/pts/v1/transaction-batch-upload");
8282

83-
$encryptedPgpBytes = PgpEncryptionUtility::encryptFileToBytes($inputFile, $pgpEncryptionCertPath);
83+
$encryptedPgpBytes = PgpEncryptionUtility::encryptFileToBytes($inputFilePath, $pgpEncryptionCertPath);
8484

85-
$pgpFileName = basename($inputFile);
85+
$pgpFileName = basename($inputFilePath);
8686
if (empty($pgpFileName) || $pgpFileName === '.' || $pgpFileName === '..') {
8787
$pgpFileName = 'file.pgp';
8888
} else {
@@ -104,7 +104,7 @@ public function uploadBatchWithP12(
104104
/**
105105
* Uploads a batch file using mutual TLS authentication with client private key and certificate.
106106
*
107-
* @param string $inputFile Path to the file to be uploaded.
107+
* @param string $inputFilePath Path to the file to be uploaded.
108108
* @param string $environmentHostname The environment hostname (e.g., api.cybersource.com).
109109
* @param string $pgpEncryptionCertPath Path to the PGP encryption certificate.
110110
* @param string $clientCertPath Path to the client certificate (PEM).
@@ -116,7 +116,7 @@ public function uploadBatchWithP12(
116116
* @throws ApiException
117117
*/
118118
public function uploadBatchWithKeyAndCert(
119-
$inputFile,
119+
$inputFilePath,
120120
$environmentHostname,
121121
$pgpEncryptionCertPath,
122122
$clientCertPath,
@@ -126,19 +126,19 @@ public function uploadBatchWithKeyAndCert(
126126
$verify_ssl = true
127127
) {
128128
if (self::$logger) {
129-
self::$logger->info("Starting batch upload with client key/cert for file: $inputFile");
129+
self::$logger->info("Starting batch upload with client key/cert for file: $inputFilePath");
130130
if ($verify_ssl === false) {
131131
self::$logger->warning("SSL verification is DISABLED for this batch upload. This is insecure and should not be used in production.");
132132
}
133133
}
134134

135-
BatchuploadUtility::validateBatchApiKeysInputs($inputFile, $environmentHostname, $pgpEncryptionCertPath, $clientKeyPath, $clientCertPath, $serverTrustCertPath);
135+
BatchuploadUtility::validateBatchApiKeysInputs($inputFilePath, $environmentHostname, $pgpEncryptionCertPath, $clientKeyPath, $clientCertPath, $serverTrustCertPath);
136136

137137
$endpointUrl = $this->getEndpointUrl($environmentHostname, "/pts/v1/transaction-batch-upload");
138138

139-
$encryptedPgpBytes = PgpEncryptionUtility::encryptFileToBytes($inputFile, $pgpEncryptionCertPath);
139+
$encryptedPgpBytes = PgpEncryptionUtility::encryptFileToBytes($inputFilePath, $pgpEncryptionCertPath);
140140

141-
$pgpFileName = basename($inputFile);
141+
$pgpFileName = basename($inputFilePath);
142142
if (empty($pgpFileName) || $pgpFileName === '.' || $pgpFileName === '..') {
143143
$pgpFileName = 'file.pgp';
144144
} else {

lib/Utilities/PGP/BatchUpload/BatchuploadUtility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,4 @@ public static function validatePathAndFile($filePath, $pathType)
103103
}
104104
}
105105

106-
}
106+
}

lib/Utilities/PGP/BatchUpload/MutualAuthUploadUtility.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,17 @@ private static function doMultipartUpload(
127127
}
128128

129129
// CA cert for server validation
130+
$defaultCaCertPath = __DIR__ . '/../../../ssl/cacert.pem';
131+
$useBlob = defined('CURLOPT_CAINFO_BLOB');
130132
if ($caCertPath) {
131-
print_r("Using custom CA cert path: $caCertPath\n");
132-
$defaultCaCertPath = __DIR__ . '/../../../ssl/cacert.pem';
133-
$defaultCa = file_exists($defaultCaCertPath) ? file_get_contents($defaultCaCertPath) : '';
134-
$userCa = file_get_contents($caCertPath);
135-
$combinedCa = rtrim($defaultCa, "\r\n") . "\n" . ltrim($userCa, "\r\n");
136-
curl_setopt($ch, CURLOPT_CAINFO_BLOB, $combinedCa);
137-
}else{
138-
$defaultCaCertPath = __DIR__ . '/../../../ssl/cacert.pem';
139-
$defaultCa = file_exists($defaultCaCertPath) ? file_get_contents($defaultCaCertPath) : '';
140-
curl_setopt($ch, CURLOPT_CAINFO_BLOB, $defaultCa);
133+
if ($useBlob) {
134+
$defaultCa = file_exists($defaultCaCertPath) ? file_get_contents($defaultCaCertPath) : '';
135+
$userCa = file_get_contents($caCertPath);
136+
$combinedCa = rtrim($defaultCa, "\r\n") . "\n" . ltrim($userCa, "\r\n");
137+
curl_setopt($ch, CURLOPT_CAINFO_BLOB, $combinedCa);
138+
} else {
139+
curl_setopt($ch, CURLOPT_CAINFO, $caCertPath);
140+
}
141141
}
142142

143143
// SSL verification

lib/Utilities/PGP/BatchUpload/PgpEncryptionUtility.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ public static function encryptFileToBytes($inputFile, $publicKeyFile)
4444
//also works without converting to string
4545
return (string)$encrypted->to_bytes();
4646
}
47-
}
47+
}

0 commit comments

Comments
 (0)