Skip to content

Commit 016787b

Browse files
committed
apiclient updates
1 parent 6ff3508 commit 016787b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

.openapi-generator/templates/ApiClient.mustache

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class ApiClient extends \GuzzleHttp\Client
157157
*
158158
* @return boolean certificate file
159159
*/
160-
public static function checkCertificatePresence($certFile, $die = false)
160+
public static function checkCertificatePresence(string $certFile, bool $die = false): bool
161161
{
162162
$found = false;
163163
if ((file_exists($certFile) === false) || (is_readable($certFile) === false)) {
@@ -172,6 +172,20 @@ class ApiClient extends \GuzzleHttp\Client
172172
return $found;
173173
}
174174

175+
public static function checkCertificate($certFile,$password): bool {
176+
return self::checkCertificatePresence($certFile) && self::checkCertificatePassword( $certFile,$password);
177+
}
178+
179+
public static function checkCertificatePassword(string $certFile, string $password): bool {
180+
$certContent = file_get_contents($certFile);
181+
if (openssl_pkcs12_read($certContent, $certs, $password) === false) {
182+
fwrite(\STDERR, 'Cannot read PKCS12 certificate file: '.$certFile.\PHP_EOL);
183+
exit(1);
184+
}
185+
return true;
186+
}
187+
188+
175189
/**
176190
* Request Identifier
177191
*

0 commit comments

Comments
 (0)