Skip to content

Commit

Permalink
Merge pull request #145 from lsnepomuceno/feature/adds-legacy-option-…
Browse files Browse the repository at this point in the history
…on-cert-conversion

feature(manage cert): adds legacy option on cert conversion
  • Loading branch information
lsnepomuceno authored May 22, 2024
2 parents c9f6b14 + d5dd644 commit 1fe9120
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Sign/ManageCert.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@

class ManageCert
{
private string $tempDir, $originalCertContent, $password, $hashKey;
private string $tempDir;
private string $originalCertContent;
private string $password;
private string $hashKey;

private bool $preservePfx = false;
private bool $isLegacy = false;

private array $parsedData;

private OpenSSLCertificate|bool $certContent;

const CIPHER = 'aes-128-cbc';
const LEGACY_FLAG = '-legacy';

private Encrypter $encrypter;

Expand All @@ -45,6 +50,12 @@ public function setPreservePfx(bool $preservePfx = true): self
return $this;
}

public function setIsLegacy(bool $isLegacy = true): self
{
$this->isLegacy = $isLegacy;
return $this;
}

/**
* @throws CertificateOutputNotFoundException
* @throws FileNotFoundException
Expand All @@ -64,8 +75,9 @@ public function fromPfx(string $pfxPath, string $password): self
}

$this->password = $password;
$output = a1TempDir(true, '.crt');
$openSslCommand = "openssl pkcs12 -in {$pfxPath} -out {$output} -nodes -password pass:'{$this->password}'";
$output = a1TempDir(true, '.crt');
$legacyFlag = $this->isLegacy ? self::LEGACY_FLAG : '';
$openSslCommand = "openssl pkcs12 -in {$pfxPath} -out {$output} -nodes -password pass:'{$this->password}' {$legacyFlag}";

runCliCommandProcesses($openSslCommand);

Expand Down

0 comments on commit 1fe9120

Please sign in to comment.