protected function getCertificateChain($certificateFile, OutputInterface $output)
{
$output->writeln('');
$certificateCounter = 1;
$certificate = new Certificate(file_get_contents($certificateFile));
$certificateChain = $certificate->getContents();
while ($certificate->hasParentInTrustChain()) {
$output->writeln('<comment>Adding certificate ' . $certificateCounter . '</comment>');
$output->writeln('<comment>downloading certificate from URL: ' . $certificate->getParentCertificateURL() . '</comment>');
$httpResponse = $this->httpClient->get($certificate->getParentCertificateURL());
if ($httpResponse->getStatusCode() != 200) {
throw new Exception('could not download certifcate at ' . $certificate->getParentCertificateURL());
}
$certificate = new Certificate((string) $httpResponse->getBody());
$certificateChain .= $certificate->getContents();
$output->writeln('<comment>added downloaded certificate to trustchain, issuer DN: ' . $certificate->getIssuerDN() . '</comment>');
$output->writeln('');
$certificateCounter++;
}
return $certificateChain;
}