File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed
.openapi-generator/templates Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff 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 *
You can’t perform that action at this time.
0 commit comments