Skip to content

Commit 1fe9120

Browse files
authored
Merge pull request #145 from lsnepomuceno/feature/adds-legacy-option-on-cert-conversion
feature(manage cert): adds legacy option on cert conversion
2 parents c9f6b14 + d5dd644 commit 1fe9120

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Sign/ManageCert.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,20 @@
1717

1818
class ManageCert
1919
{
20-
private string $tempDir, $originalCertContent, $password, $hashKey;
20+
private string $tempDir;
21+
private string $originalCertContent;
22+
private string $password;
23+
private string $hashKey;
2124

2225
private bool $preservePfx = false;
26+
private bool $isLegacy = false;
2327

2428
private array $parsedData;
2529

2630
private OpenSSLCertificate|bool $certContent;
2731

2832
const CIPHER = 'aes-128-cbc';
33+
const LEGACY_FLAG = '-legacy';
2934

3035
private Encrypter $encrypter;
3136

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

53+
public function setIsLegacy(bool $isLegacy = true): self
54+
{
55+
$this->isLegacy = $isLegacy;
56+
return $this;
57+
}
58+
4859
/**
4960
* @throws CertificateOutputNotFoundException
5061
* @throws FileNotFoundException
@@ -64,8 +75,9 @@ public function fromPfx(string $pfxPath, string $password): self
6475
}
6576

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

7082
runCliCommandProcesses($openSslCommand);
7183

0 commit comments

Comments
 (0)