Skip to content

Commit

Permalink
Updated Bank's X509 generator.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-svirin committed Jan 1, 2025
1 parent e41f71c commit 1d52564
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ docker-php php:
check:
cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpcbf
cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpcs
cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpstan
cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpstan --xdebug
cd docker && docker-compose -p ebics-client-php exec php-cli-ebics-client-php ./vendor/bin/phpunit

credentials-pack:
Expand Down
23 changes: 10 additions & 13 deletions src/Models/X509/BankX509Generator.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,12 @@ public function setCertificateOptionsByBank(Bank $bank): void
*/
private function resolveCountryName(string $url): string
{
/** @var string[] */
$urlArr = parse_url($url);
if (!isset($urlArr['host'])) {
$host = parse_url($url, PHP_URL_HOST);
if (empty($host)) {
throw new LogicException('Host not parsed.');
}

$explode = explode('.', $urlArr['host']);
$explode = explode('.', $host);
$domain = end($explode);

switch ($domain) {
Expand All @@ -72,13 +71,12 @@ private function resolveCountryName(string $url): string
*/
private function resolveDomainName(string $url): string
{
/** @var string[] */
$urlArr = parse_url($url);
if (!isset($urlArr['host'])) {
$host = parse_url($url, PHP_URL_HOST);
if (empty($host)) {
throw new LogicException('Host not parsed.');
}

$explode = explode('.', $urlArr['host']);
$explode = explode('.', $host);
$explode[0] = '*';

return implode('.', $explode);
Expand All @@ -89,14 +87,13 @@ private function resolveDomainName(string $url): string
*/
private function resolveEstablishmentName(string $url): string
{
/** @var string[] */
$urlArr = parse_url($url);
if (!isset($urlArr['host'])) {
$host = parse_url($url, PHP_URL_HOST);
if (empty($host)) {
throw new LogicException('Host not parsed.');
}

$explode = explode('.', $urlArr['host']);
$explode = explode('.', $host);

return ucfirst($explode[1]);
return ucfirst($explode[max(count($explode) - 2, 0)]);
}
}

0 comments on commit 1d52564

Please sign in to comment.