Skip to content
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
174 commits
Select commit Hold shift + click to select a range
8bae348
Deprecate commands in favor of run
jderusse Jul 4, 2019
9eeb20a
Adding Gandi.Net DNS solver class
Jul 18, 2019
62d9b1b
CS fixes
Jul 18, 2019
83e47d3
Removed unused code
Jul 19, 2019
c08bb1f
Update composer.json
xiaohuilam Jul 28, 2019
ca5a355
enhancement
xiaohuilam Jul 29, 2019
9b572c9
fix
xiaohuilam Jul 29, 2019
2e5997a
done auth
xiaohuilam Jul 29, 2019
85778e1
support csrEager
xiaohuilam Jul 30, 2019
5a63b88
update
xiaohuilam Jul 30, 2019
e75810e
trustocean can't delete. because it requires async to verify
xiaohuilam Jul 30, 2019
24491ec
support rfc8555 csrEager
xiaohuilam Jul 30, 2019
9712e7e
fix
xiaohuilam Jul 30, 2019
9bb6dd4
暂时屏蔽删除,因为comodoca是异步的
xiaohuilam Jul 30, 2019
126ebb8
csrEager
xiaohuilam Jul 30, 2019
9fe2f20
fixbug #1, implement csrEager
xiaohuilam Jul 30, 2019
51ce2fb
update change log
xiaohuilam Jul 30, 2019
297ee09
Merge pull request #4 from aik099/gandi-dns-solver-feat
xiaohuilam Jul 30, 2019
d865632
Merge pull request #162 from aik099/gandi-dns-solver-feat
jderusse Jul 30, 2019
d522db7
stash
xiaohuilam Jul 30, 2019
0c6088d
rename to trustocean/acme-client
xiaohuilam Jul 31, 2019
d550946
done support for Aliyun DNS service
xiaohuilam Jul 31, 2019
7ac8673
Merge branch 'master' of https://github.com/acmephp/acmephp into feat…
xiaohuilam Jul 31, 2019
1675a73
enhancement
xiaohuilam Jul 31, 2019
50bf15f
Merge pull request #5 from trustocean/feat-solver-aliyun
xiaohuilam Jul 31, 2019
26b54bb
update travis to build phar
xiaohuilam Jul 31, 2019
a28ba03
remove php5.5
xiaohuilam Jul 31, 2019
d9e446f
update
xiaohuilam Jul 31, 2019
898534d
update
xiaohuilam Jul 31, 2019
bbdc836
fix
xiaohuilam Jul 31, 2019
97e512c
enhancement
xiaohuilam Jul 31, 2019
eb425e6
test
xiaohuilam Jul 31, 2019
d84a112
fix
xiaohuilam Jul 31, 2019
6d113ee
fix
xiaohuilam Jul 31, 2019
985d918
fix
xiaohuilam Jul 31, 2019
6c79690
fix
xiaohuilam Jul 31, 2019
040b5b5
fix
xiaohuilam Jul 31, 2019
856526d
fix phar build
xiaohuilam Jul 31, 2019
62a5bd4
fix
xiaohuilam Jul 31, 2019
d8ca2dc
stash
xiaohuilam Jul 31, 2019
1e07b36
自动打包 Phar 完成
xiaohuilam Jul 31, 2019
5cad995
done phar auto compile
xiaohuilam Jul 31, 2019
8541342
statsh
xiaohuilam Aug 1, 2019
05a2f39
fix
xiaohuilam Aug 1, 2019
40558ea
close #17
xiaohuilam Aug 1, 2019
67b8285
Merge branch 'feat-install-aliyun-waf'
xiaohuilam Aug 1, 2019
1a17f6e
fix style ci
xiaohuilam Aug 1, 2019
1e9c675
Merge branch 'feat-install-aliyun-waf'
xiaohuilam Aug 1, 2019
723de09
style ci
xiaohuilam Aug 1, 2019
2d88030
Merge pull request #161 from jderusse/deprecate-commands
jderusse Aug 1, 2019
e9fefc3
stash
xiaohuilam Aug 1, 2019
91049e3
Remove try...catch wrapper
xiaohuilam Aug 1, 2019
0d522f7
Update InstallAliyunWafAction.php
xiaohuilam Aug 1, 2019
d20150c
Merge branch 'feat-install-aliyun-waf'
xiaohuilam Aug 1, 2019
505d4c2
stash
xiaohuilam Aug 1, 2019
0501e56
register in services
xiaohuilam Aug 1, 2019
2400302
remove wrong conf
xiaohuilam Aug 1, 2019
3292b41
fix
xiaohuilam Aug 1, 2019
c2c4720
Merge branch 'feat-install-aliyun-cdn'
xiaohuilam Aug 1, 2019
634ef1b
修复 requestcert后 installcert 报错的问题
xiaohuilam Aug 1, 2019
6d17d7b
remove useless sh
xiaohuilam Aug 1, 2019
8684a94
Merge branch 'master' of https://github.com/acmephp/acmephp
xiaohuilam Aug 1, 2019
bce7829
fixbug
xiaohuilam Aug 1, 2019
dcd1ad7
fixbug
xiaohuilam Aug 1, 2019
2a51a4d
Merge branch 'feat-install-aliyun-waf'
xiaohuilam Aug 1, 2019
dd40a03
Merge branch 'feat-install-aliyun-cdn'
xiaohuilam Aug 1, 2019
45037e1
Merge branch 'master' of https://github.com/acmephp/acmephp into feat…
xiaohuilam Aug 1, 2019
ce4bb92
style ci
xiaohuilam Aug 1, 2019
9203dec
Merge pull request #163 from trustocean/feat-install-aliyun-waf
jderusse Aug 1, 2019
51da67e
Merge branch 'master' of https://github.com/acmephp/acmephp into feat…
xiaohuilam Aug 1, 2019
22b674d
Merge branch 'master' of https://github.com/acmephp/acmephp
xiaohuilam Aug 2, 2019
c329846
重名时阿里云会报错
xiaohuilam Aug 2, 2019
6928dbf
重名时阿里云会报错
xiaohuilam Aug 2, 2019
d39d70d
Merge branch 'feat-install-aliyun-waf' of github.com:trustocean/acme-…
xiaohuilam Aug 2, 2019
35ab635
Merge branch 'feat-install-aliyun-cdn' of github.com:trustocean/acme-…
xiaohuilam Aug 2, 2019
a22f393
Merge branch 'feat-install-aliyun-cdn'
xiaohuilam Aug 2, 2019
92ecf29
Merge branch 'feat-install-aliyun-waf'
xiaohuilam Aug 2, 2019
bddfd66
done dnspod(Tencentcloud NS) support
xiaohuilam Aug 2, 2019
7710420
style ci
xiaohuilam Aug 2, 2019
5dfef21
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 2, 2019
5781c34
style ci
xiaohuilam Aug 2, 2019
88201a0
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 2, 2019
6a09ffb
style ci
xiaohuilam Aug 2, 2019
4c6cc3c
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 2, 2019
aaf359b
style ci
xiaohuilam Aug 2, 2019
8e82526
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 2, 2019
6ec120e
add checkSign method
xiaohuilam Aug 2, 2019
4c3ce4c
Merge branch 'feat-check-sign'
xiaohuilam Aug 2, 2019
222f184
重名时阿里云会报错
xiaohuilam Aug 2, 2019
d060f0c
style ci, no spacing near dot
xiaohuilam Aug 2, 2019
6eacee7
style ci
xiaohuilam Aug 2, 2019
6446d96
Merge branch 'feat-install-aliyun-waf'
xiaohuilam Aug 2, 2019
b1a556a
Merge branch 'feat-install-aliyun-cdn'
xiaohuilam Aug 2, 2019
1e7bbc1
add the challenge type parameter when initOrder
xiaohuilam Aug 3, 2019
58db1ba
Merge branch 'master' of github.com:trustocean/acme-client
xiaohuilam Aug 3, 2019
697a6ec
update
xiaohuilam Aug 3, 2019
ce40366
fixbug
xiaohuilam Aug 3, 2019
fe49856
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 3, 2019
144c49b
fix
xiaohuilam Aug 3, 2019
5307d84
getTopLevelDomain func born from GandiSolver isn't reliable, should e…
xiaohuilam Aug 3, 2019
2e6f3ca
style ci
xiaohuilam Aug 3, 2019
8137324
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 3, 2019
e341ca7
fix wildcard small pattern problem
xiaohuilam Aug 3, 2019
4c5c90c
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 3, 2019
8b1597c
style ci
xiaohuilam Aug 3, 2019
79cd99a
Merge branch 'feat-solver-dnspod'
xiaohuilam Aug 3, 2019
ce561b0
enhancement
xiaohuilam Aug 6, 2019
fe15f15
修复DNSPod对于同一主机名CNAME不能共存的bug
xiaohuilam Aug 7, 2019
dcf3aeb
fixbug
xiaohuilam Aug 7, 2019
06dcff7
resolved #19
xiaohuilam Aug 15, 2019
00dd962
Merge pull request #22 from trustocean/feat-install-tencentcloud-cdn
xiaohuilam Aug 15, 2019
6b65f1a
Merge pull request #164 from trustocean/feat-install-aliyun-cdn
jderusse Aug 27, 2019
2c0dfc8
Merge pull request #23 from acmephp/master
xiaohuilam Aug 27, 2019
44a6aee
fixbug
xiaohuilam Aug 28, 2019
e6ea8f4
Merge branch 'master' of github.com:trustocean/acme-client
xiaohuilam Aug 28, 2019
bdc1e9e
fixbug
xiaohuilam Oct 6, 2019
8e17037
Update upload_phar.sh
xiaohuilam Oct 6, 2019
11a6568
fixbug
xiaohuilam Oct 6, 2019
1c3c80e
Merge branch 'master' of github.com:trustocean/acme-client
xiaohuilam Oct 6, 2019
5f47ad7
fixbug
xiaohuilam Oct 6, 2019
51ed68d
fixbug
xiaohuilam Oct 6, 2019
5eaa471
Merge pull request #24 from digitalsign/feat-solver-aliyun
xiaohuilam Oct 7, 2019
e22baa9
Merge branch 'master' into feat-solver-dnspod
xiaohuilam Oct 7, 2019
b320d72
Fix unresolvable check url bug
xiaohuilam Nov 6, 2019
ea0a21c
fixbug
xiaohuilam Nov 6, 2019
c43a234
Update DistinguishedName.php
xiaohuilam Nov 13, 2019
d57efaa
修复DNSPod解析的bug
xiaohuilam Nov 14, 2019
9e01503
修复DNSPod解析的bug
xiaohuilam Nov 14, 2019
2ff71f7
fixbug
xiaohuilam Nov 15, 2019
6c390f6
fix dns check does not support cname bug
xiaohuilam Nov 15, 2019
ae3cda1
fixbug
xiaohuilam Nov 15, 2019
017a920
Merge branch 'feat-solver-dnspod'
xiaohuilam Nov 15, 2019
ca888f0
remove uses alias, change exception throwing to `AcmeDnsResolutionExc…
xiaohuilam Nov 15, 2019
d752b16
Merge branch 'feat-solver-dnspod'
xiaohuilam Nov 15, 2019
bb20317
Tencentcloud dns challenge err debug
xiaohuilam Nov 23, 2019
9fd2220
修复Qcloud SDK覆盖异常的傻逼操作 https://github.com/QcloudApi/qcloudapi-sdk-php/…
xiaohuilam Nov 23, 2019
548b609
Tencentcloud dns challenge err debug
xiaohuilam Nov 23, 2019
4af7fd1
修复Qcloud SDK覆盖异常的傻逼操作 https://github.com/QcloudApi/qcloudapi-sdk-php/…
xiaohuilam Nov 23, 2019
7c2a9ff
Merge branch 'feat-solver-dnspod'
xiaohuilam Nov 23, 2019
5a2d100
fix
xiaohuilam Nov 23, 2019
d21c37b
timeout configurable
xiaohuilam Nov 23, 2019
2e1e108
fixbug
xiaohuilam Nov 23, 2019
a21445e
enhancement
xiaohuilam Nov 26, 2019
21535ff
fix
xiaohuilam Nov 26, 2019
f139c30
fixbug
xiaohuilam Nov 26, 2019
b8ae9eb
fixbug
xiaohuilam Nov 26, 2019
2959ec1
add doc
xiaohuilam Nov 26, 2019
3628106
集成DNSPod自有API,不再建议使用腾讯云API
xiaohuilam Nov 26, 2019
fee5ef2
fixbug
xiaohuilam Nov 26, 2019
324406c
fixbug
xiaohuilam Nov 26, 2019
61ac41d
fixbug
xiaohuilam Nov 26, 2019
77b6f5b
fixbug
xiaohuilam Nov 26, 2019
2d8b8ec
jeremykendall/php-domain-parser can't run in phar
xiaohuilam Nov 26, 2019
c6a7bb4
腾讯云CDN安装需要 base64 encode
xiaohuilam Nov 26, 2019
6ad71ba
update DataSigner to use web-token for ECDSA
xiaohuilam Nov 28, 2019
f0e9422
Add php 7.3 and 7.4
jderusse Dec 9, 2019
0d09084
Merge pull request #180 from jderusse/fix-test
jderusse Dec 9, 2019
dbc895b
DNSPOD不接受TXT值+名重复
xiaohuilam Dec 11, 2019
c592b85
added orderNotReady error type
pauladams8 Dec 11, 2019
937a2f7
Merge pull request #182 from pauladams8/master
jderusse Dec 12, 2019
25a12e3
Split Sign and Request
jderusse Dec 13, 2019
028470a
fix the wrong return type
Dec 16, 2019
ec1bbba
fix the wrong return type
Dec 16, 2019
b86d2d6
Merge pull request #184 from miranovy/master
jderusse Dec 16, 2019
df8f156
Merge pull request #183 from jderusse/split-request
jderusse Dec 17, 2019
24b8575
Fix getIssuerCertificate return type
Dec 17, 2019
d031223
Merge pull request #185 from miranovy/master
jderusse Dec 17, 2019
b796512
Release of new version 1.2.0
tgalopin Jan 15, 2020
c5de9ad
当check为false时候,跳过费时的检查步骤
xiaohuilam Jan 18, 2020
edb3d26
Update composer.json
xiaohuilam Mar 3, 2020
2a59ecc
monolog/monolog ^1.19|^2.0
Mar 17, 2020
a9ea89c
Merge branch 'master' of https://github.com/acmephp/acmephp
Mar 17, 2020
0ba4c4d
修复 bug
Mar 17, 2020
486dbb6
fixbug
Mar 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "acmephp/acmephp",
"name": "trustocean/acmephp",
"description": "Let's Encrypt client written in PHP",
"type": "project",
"license": "MIT",
Expand Down
51 changes: 50 additions & 1 deletion src/Cli/Command/AuthorizeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,21 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use AcmePhp\Cli\Command\Helper\KeyOptionCommandTrait;
use AcmePhp\Ssl\CertificateRequest;

/**
* @author Titouan Galopin <galopintitouan@gmail.com>
*/
class AuthorizeCommand extends AbstractCommand
{
use KeyOptionCommandTrait;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为 csrEager 需要生成 KEY


/**
* @var RepositoryInterface
*/
private $repository;

/**
* {@inheritdoc}
*/
Expand All @@ -34,6 +43,14 @@ protected function configure()
->setDefinition([
new InputOption('solver', 's', InputOption::VALUE_REQUIRED, 'The type of challenge solver to use (available: http, dns, route53)', 'http'),
new InputArgument('domains', InputArgument::IS_ARRAY | InputArgument::REQUIRED, 'List of domains to ask an authorization for'),
new InputOption('country', null, InputOption::VALUE_REQUIRED, 'Your country two-letters code (field "C" of the distinguished name, for instance: "US")'),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为 csrEager 参数需要

new InputOption('province', null, InputOption::VALUE_REQUIRED, 'Your country province (field "ST" of the distinguished name, for instance: "California")'),
new InputOption('locality', null, InputOption::VALUE_REQUIRED, 'Your locality (field "L" of the distinguished name, for instance: "Mountain View")'),
new InputOption('organization', null, InputOption::VALUE_REQUIRED, 'Your organization/company (field "O" of the distinguished name, for instance: "Acme PHP")'),
new InputOption('unit', null, InputOption::VALUE_REQUIRED, 'Your unit/department in your organization (field "OU" of the distinguished name, for instance: "Sales")'),
new InputOption('email', null, InputOption::VALUE_REQUIRED, 'Your e-mail address (field "E" of the distinguished name)'),
new InputOption('alternative-name', 'a', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Alternative domains for this certificate'),
new InputOption('key-type', 'k', InputOption::VALUE_REQUIRED, 'The type of private key used to sign certificates (one of RSA, EC)', 'RSA'),
])
->setDescription('Ask the ACME server for an authorization token to check you are the owner of a domain')
->setHelp(<<<'EOF'
Expand All @@ -56,8 +73,11 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->repository = $this->getRepository();

$client = $this->getClient();
$domains = $input->getArgument('domains');
$keyType = $input->getOption('key-type');

$solverName = strtolower($input->getOption('solver'));

Expand All @@ -68,8 +88,37 @@ protected function execute(InputInterface $input, OutputInterface $output)
$solver = $solverLocator->get($solverName);
$this->debug('Solver found', ['name' => $solverName]);

$alternativeNames = $domains;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

生成 CSR 的逻辑. 初始化订单时候一起提交

$domain = $alternativeNames[0];
sort($alternativeNames);

$introduction = <<<'EOF'

There is currently no certificate for domain %s in the Acme PHP storage. As it is the
first time you request a certificate for this domain, some configuration is required.

<info>Generating domain key pair...</info>
EOF;

$this->info(sprintf($introduction, $domain));

/* @var KeyPair $domainKeyPair */
$domainKeyPair = $this->getContainer()->get('ssl.key_pair_generator')->generateKeyPair(
$this->createKeyOption($keyType)
);
$this->repository->storeDomainKeyPair($domain, $domainKeyPair);

$this->debug('Domain key pair generated and stored', [
'domain' => $domain,
'public_key' => $domainKeyPair->getPublicKey()->getPEM(),
]);
$distinguishedName = $this->getOrCreateDistinguishedName($domain, $alternativeNames);
$this->notice('Distinguished name informations have been stored locally for this domain (they won\'t be asked on renewal).');
$this->notice(sprintf('Loading the order related to the domains %s ...', implode(', ', $domains)));
$csr = new CertificateRequest($distinguishedName, $domainKeyPair);

$this->notice(sprintf('Requesting an authorization token for domains %s ...', implode(', ', $domains)));
$order = $client->requestOrder($domains);
$order = $client->requestOrder($domains, $csr);
$this->notice('The authorization tokens was successfully fetched!');
$authorizationChallengesToSolve = [];
foreach ($order->getAuthorizationsChallenges() as $domainKey => $authorizationChallenges) {
Expand Down
58 changes: 58 additions & 0 deletions src/Cli/Command/Helper/KeyOptionCommandTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

use AcmePhp\Ssl\Generator\EcKey\EcKeyOption;
use AcmePhp\Ssl\Generator\RsaKey\RsaKeyOption;
use AcmePhp\Ssl\DistinguishedName;

/**
* @author Jérémy Derussé <jeremy@derusse.com>
Expand All @@ -30,4 +31,61 @@ private function createKeyOption($keyType)
throw new \InvalidArgumentException(sprintf('The keyType "%s" is not valid. Supported types are: RSA, EC', strtoupper($keyType)));
}
}


/**
* Retrieve the stored distinguishedName or create a new one if needed.
*
* @param string $domain
* @param array $alternativeNames
*
* @return DistinguishedName
*/
private function getOrCreateDistinguishedName($domain, array $alternativeNames)
{
if ($this->repository->hasDomainDistinguishedName($domain)) {
$original = $this->repository->loadDomainDistinguishedName($domain);

$distinguishedName = new DistinguishedName(
$domain,
$this->input->getOption('country') ?: $original->getCountryName(),
$this->input->getOption('province') ?: $original->getStateOrProvinceName(),
$this->input->getOption('locality') ?: $original->getLocalityName(),
$this->input->getOption('organization') ?: $original->getOrganizationName(),
$this->input->getOption('unit') ?: $original->getOrganizationalUnitName(),
$this->input->getOption('email') ?: $original->getEmailAddress(),
$alternativeNames
);
} else {
// Ask DistinguishedName
$distinguishedName = new DistinguishedName(
$domain,
$this->input->getOption('country'),
$this->input->getOption('province'),
$this->input->getOption('locality'),
$this->input->getOption('organization'),
$this->input->getOption('unit'),
$this->input->getOption('email'),
$alternativeNames
);

/** @var DistinguishedNameHelper $helper */
$helper = $this->getHelper('distinguished_name');

if (!$helper->isReadyForRequest($distinguishedName)) {
$this->info("\n\nSome informations about you or your company are required for the certificate:\n");

$distinguishedName = $helper->ask(
$this->getHelper('question'),
$this->input,
$this->output,
$distinguishedName
);
}
}

$this->repository->storeDomainDistinguishedName($domain, $distinguishedName);

return $distinguishedName;
}
}
56 changes: 0 additions & 56 deletions src/Cli/Command/RequestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,60 +342,4 @@ private function executeRenewal($domain, array $alternativeNames)
throw $e;
}
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

挪到 Trait 和 initializeOrder 方法共用

/**
* Retrieve the stored distinguishedName or create a new one if needed.
*
* @param string $domain
* @param array $alternativeNames
*
* @return DistinguishedName
*/
private function getOrCreateDistinguishedName($domain, array $alternativeNames)
{
if ($this->repository->hasDomainDistinguishedName($domain)) {
$original = $this->repository->loadDomainDistinguishedName($domain);

$distinguishedName = new DistinguishedName(
$domain,
$this->input->getOption('country') ?: $original->getCountryName(),
$this->input->getOption('province') ?: $original->getStateOrProvinceName(),
$this->input->getOption('locality') ?: $original->getLocalityName(),
$this->input->getOption('organization') ?: $original->getOrganizationName(),
$this->input->getOption('unit') ?: $original->getOrganizationalUnitName(),
$this->input->getOption('email') ?: $original->getEmailAddress(),
$alternativeNames
);
} else {
// Ask DistinguishedName
$distinguishedName = new DistinguishedName(
$domain,
$this->input->getOption('country'),
$this->input->getOption('province'),
$this->input->getOption('locality'),
$this->input->getOption('organization'),
$this->input->getOption('unit'),
$this->input->getOption('email'),
$alternativeNames
);

/** @var DistinguishedNameHelper $helper */
$helper = $this->getHelper('distinguished_name');

if (!$helper->isReadyForRequest($distinguishedName)) {
$this->info("\n\nSome informations about you or your company are required for the certificate:\n");

$distinguishedName = $helper->ask(
$this->getHelper('question'),
$this->input,
$this->output,
$distinguishedName
);
}
}

$this->repository->storeDomainDistinguishedName($domain, $distinguishedName);

return $distinguishedName;
}
}
34 changes: 31 additions & 3 deletions src/Cli/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$certificate
);
} else {
$order = $this->challengeDomains($domainConfig);
$order = $this->challengeDomains($domainConfig, $keyOption);
$response = $this->requestCertificate($order, $domainConfig, $keyOption);
}

Expand Down Expand Up @@ -228,7 +228,7 @@ private function requestCertificate(CertificateOrder $order, $domainConfig, KeyO
return $response;
}

private function challengeDomains(array $domainConfig)
private function challengeDomains(array $domainConfig, KeyOption $keyOption)
{
$solverConfig = $domainConfig['solver'];
$domain = $domainConfig['domain'];
Expand All @@ -246,8 +246,36 @@ private function challengeDomains(array $domainConfig)
$client = $this->getClient();
$domains = array_unique(array_merge([$domain], $domainConfig['subject_alternative_names']));


Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

生成 CSR

$domain = $domainConfig['domain'];
$this->output->writeln(sprintf('<comment>Requesting certificate for domain %s...</comment>', $domain));

$repository = $this->getRepository();
$client = $this->getClient();
$distinguishedName = new DistinguishedName(
$domainConfig['domain'],
$domainConfig['distinguished_name']['country'],
$domainConfig['distinguished_name']['state'],
$domainConfig['distinguished_name']['locality'],
$domainConfig['distinguished_name']['organization_name'],
$domainConfig['distinguished_name']['organization_unit_name'],
$domainConfig['distinguished_name']['email_address'],
$domainConfig['subject_alternative_names']
);

if ($repository->hasDomainKeyPair($domain)) {
$domainKeyPair = $repository->loadDomainKeyPair($domain);
} else {
$domainKeyPair = $this->getContainer()->get('ssl.key_pair_generator')->generateKeyPair($keyOption);
$repository->storeDomainKeyPair($domain, $domainKeyPair);
}

$repository->storeDomainDistinguishedName($domain, $distinguishedName);

$csr = new CertificateRequest($distinguishedName, $domainKeyPair);

$this->output->writeln('<comment>Requesting certificate order...</comment>');
$order = $client->requestOrder($domains);
$order = $client->requestOrder($domains, $csr);

$authorizationChallengesToSolve = [];
foreach ($order->getAuthorizationsChallenges() as $domain => $authorizationChallenges) {
Expand Down
13 changes: 11 additions & 2 deletions src/Core/AcmeClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,15 @@ public function requestAuthorization($domain)
/**
* {@inheritdoc}
*/
public function requestOrder(array $domains)
public function requestOrder(array $domains, $csr = null)
{
Assert::allStringNotEmpty($domains, 'requestOrder::$domains expected a list of strings. Got: %s');

$humanText = ['-----BEGIN CERTIFICATE REQUEST-----', '-----END CERTIFICATE REQUEST-----'];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

将 CSR 内容转换成 UrlSafe

$csrContent = $this->csrSigner->signCertificateRequest($csr);
$csrContent = trim(str_replace($humanText, '', $csrContent));
$csrContent = trim($this->getHttpClient()->getBase64Encoder()->encode(base64_decode($csrContent)));

$payload = [
'identifiers' => array_map(
function ($domain) {
Expand All @@ -145,6 +150,7 @@ function ($domain) {
},
array_values($domains)
),
'csr' => $csrContent,
];

$response = $this->getHttpClient()->signedKidRequest('POST', $this->getResourceUrl(ResourcesDirectory::NEW_ORDER), $this->getResourceAccount(), $payload);
Expand Down Expand Up @@ -360,7 +366,10 @@ private function createAuthorizationChallenge($domain, array $response)
$response['type'],
$response['url'],
$response['token'],
$response['token'].'.'.$base64encoder->encode($this->getHttpClient()->getJWKThumbprint())
isset($response['filecontent']) ? $response['filecontent'] : ($response['token'].'.'.$base64encoder->encode($this->getHttpClient()->getJWKThumbprint())),
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

因为 trustocean (comodoca) 的验证路径/文件名/内容不一致. 特意加上的补充参数

isset($response['path']) ? $response['path'] : null,
isset($response['verifyurl']) ? $response['verifyurl'] : null,
isset($response['filecontent']) ? $response['filecontent'] : null
);
}
}
2 changes: 1 addition & 1 deletion src/Core/AcmeClientV2Interface.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface AcmeClientV2Interface extends AcmeClientInterface
*
* @return CertificateOrder the Order returned by the Certificate Authority
*/
public function requestOrder(array $domains);
public function requestOrder(array $domains, $csr = null);

/**
* Request a certificate for the given domain.
Expand Down
3 changes: 1 addition & 2 deletions src/Core/Challenge/Http/FilesystemSolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public function solve(AuthorizationChallenge $authorizationChallenge)
public function cleanup(AuthorizationChallenge $authorizationChallenge)
{
$checkPath = $this->extractor->getCheckPath($authorizationChallenge);

$this->filesystem->delete($checkPath);
//$this->filesystem->delete($checkPath);
}
}
2 changes: 1 addition & 1 deletion src/Core/Challenge/Http/HttpDataExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function getCheckUrl(AuthorizationChallenge $authorizationChallenge)
public function getCheckPath(AuthorizationChallenge $authorizationChallenge)
{
return sprintf(
'/.well-known/acme-challenge/%s',
$authorizationChallenge->getPath() ? ($authorizationChallenge->getPath() . '%s') : '/.well-known/acme-challenge/%s',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/.well-known/acme-challenge/ => /.well-known/pki-validation/

$authorizationChallenge->getToken()
);
}
Expand Down
1 change: 1 addition & 0 deletions src/Core/Filesystem/Adapter/FlysystemAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function write($path, $content)

public function delete($path)
{
return;
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep un-deleted. because when program run here, comodo is not verified for certain yet.

$isOnRemote = $this->filesystem->has($path);
if ($isOnRemote && !$this->filesystem->delete($path)) {
throw $this->createRuntimeException($path, 'delete');
Expand Down
Loading