mirror of
https://github.com/anikeen-com/yaac.git
synced 2026-03-17 15:46:12 +00:00
Add support to get certificate chain as separate certificates
- https://github.com/afosto/yaac/issues/10 - The purpose is to support web servers such as apache < 2.4.8 where the intermediate certificate needs to be separate - Add method Helper::splitCertificate to parse cert chain - Add param to Certificate::getCertificate($asChain = true) to maintain bc and get the certificate with or without chain - Add method Certificate::getIntermediateCertificate to get just the intermediate certificate
This commit is contained in:
@@ -17,6 +17,16 @@ class Certificate
|
||||
*/
|
||||
protected $certificate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $certificateNoChain;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $intermediateCertificate;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
@@ -39,6 +49,7 @@ class Certificate
|
||||
$this->privateKey = $privateKey;
|
||||
$this->csr = $csr;
|
||||
$this->certificate = $certificate;
|
||||
list($this->certificateNoChain, $this->intermediateCertificate) = Helper::splitCertificate($certificate);
|
||||
$this->expiryDate = Helper::getCertExpiryDate($certificate);
|
||||
}
|
||||
|
||||
@@ -64,9 +75,18 @@ class Certificate
|
||||
* Return the certificate as a multi line string
|
||||
* @return string
|
||||
*/
|
||||
public function getCertificate(): string
|
||||
public function getCertificate($asChain = true): string
|
||||
{
|
||||
return $this->certificate;
|
||||
return $asChain ? $this->certificate : $this->certificateNoChain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the intermediate certificate as a multi line string
|
||||
* @return string
|
||||
*/
|
||||
public function getIntermediateCertificate(): string
|
||||
{
|
||||
return $this->intermediateCertificate;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user