저자: Jérémy Derussé (jeremy@derusse.com)
예제 #1
0
 /**
  * {@inheritdoc}
  */
 public function storeCertificateResponse(CertificateResponse $certificateResponse)
 {
     $distinguishedName = $certificateResponse->getCertificateRequest()->getDistinguishedName();
     $domain = $distinguishedName->getCommonName();
     $this->storeDomainKeyPair($domain, $certificateResponse->getCertificateRequest()->getKeyPair());
     $this->storeDomainDistinguishedName($domain, $distinguishedName);
     $this->storeDomainCertificate($domain, $certificateResponse->getCertificate());
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 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);
 }