AcmePhp\Cli\Action\BuildNginxProxyAction::handle PHP Method

handle() public method

public handle ( $config, CertificateResponse $response )
$response AcmePhp\Ssl\CertificateResponse
    public function handle($config, CertificateResponse $response)
    {
        $domain = $response->getCertificateRequest()->getDistinguishedName()->getCommonName();
        $privateKey = $response->getCertificateRequest()->getKeyPair()->getPrivateKey();
        $certificate = $response->getCertificate();
        $this->repository->save('nginxproxy/' . $domain . '.key', $this->serializer->serialize($privateKey, PemEncoder::FORMAT));
        // Simple certificate
        $certPem = $this->serializer->serialize($certificate, PemEncoder::FORMAT);
        // Issuer chain
        $issuerChain = [];
        $issuerCertificate = $certificate->getIssuerCertificate();
        while (null !== $issuerCertificate) {
            $issuerChain[] = $this->serializer->serialize($issuerCertificate, PemEncoder::FORMAT);
            $issuerCertificate = $issuerCertificate->getIssuerCertificate();
        }
        $chainPem = implode("\n", $issuerChain);
        // Full chain
        $fullChainPem = $certPem . $chainPem;
        $this->repository->save('nginxproxy/' . $domain . '.crt', $fullChainPem);
    }
BuildNginxProxyAction