예제 #1
0
 public function testRegister()
 {
     $account = new Account('hyn-test', '*****@*****.**');
     $certificate = new Certificate($account);
     $certificate->addHostname('test.hyn.me');
     var_dump($certificate->request());
 }
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @return Certificate
  * @throws \Exception
  */
 protected function runHttpMethod(InputInterface $input, OutputInterface $output)
 {
     $public_path = rtrim($input->getOption('http'), '/');
     $challenge_path = "{$public_path}/.well-known/acme-challenge/";
     if (!is_dir($challenge_path)) {
         if (!mkdir($challenge_path, 0755, true)) {
             $output->writeln('<error>Unable to generate the acme challenge directory in the specified public directory, manually create path or set ownership to: ' . $challenge_path);
             return;
         }
     }
     // Set the challenge path.
     Http01Solver::setChallengePublicPath($challenge_path);
     $account = new Account($input->getOption('account'), $input->getOption('email'));
     $certificate = new Certificate($account);
     foreach ($input->getArgument('hostnames') as $hostname) {
         $certificate->addHostname($hostname);
     }
     $result = $certificate->request();
     $certificate->setCertificate(Arr::get($result, 0));
     $certificate->setBundle(Arr::get($result, 1));
     return $certificate;
 }