Skip to content

Commit 20dc2fc

Browse files
committed
Remove default CA from --provider, require explicit choice
Mirrors the library's "no hidden defaults" principle. --provider is now required; omitting it fails with a descriptive error. Updates README table and adds a test for the missing-provider case.
1 parent 0ab9c48 commit 20dc2fc

3 files changed

Lines changed: 23 additions & 5 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ If a valid certificate already exists and expiry is more than `--days` away, the
138138
| `--domain` | `-d` || Domain to include on the certificate. Repeat for SANs: `--domain example.com --domain www.example.com` |
139139
| `--email` | `-e` || Contact email registered with the ACME account |
140140
| `--webroot` | `-w` || Webroot path for HTTP-01. CoyoteCert writes tokens under `.well-known/acme-challenge/` |
141-
| `--provider` | `-p` | `letsencrypt` | CA to use. See provider table below |
141+
| `--provider` | `-p` | | CA to use. See provider table below. **Required** |
142142
| `--storage` | `-s` | `./certs` | Directory to read/write certificates and account keys |
143143
| `--days` || `30` | Renew when fewer than this many days remain before expiry |
144144
| `--key-type` || `ec256` | Certificate key type: `ec256`, `ec384`, `rsa2048`, `rsa4096` |

src/Console/Command/IssueCommand.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ protected function configure(): void
2727
->addOption('domain', 'd', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Domain name(s) to include on the certificate')
2828
->addOption('email', 'e', InputOption::VALUE_REQUIRED, 'Contact email for the ACME account')
2929
->addOption('webroot', 'w', InputOption::VALUE_REQUIRED, 'Webroot path for HTTP-01 challenge (.well-known/acme-challenge will be written here)')
30-
->addOption('provider', 'p', InputOption::VALUE_REQUIRED, 'CA to use: letsencrypt, letsencrypt-staging, zerossl, google, buypass, buypass-staging, sslcom', 'letsencrypt')
30+
->addOption('provider', 'p', InputOption::VALUE_REQUIRED, 'CA to use: letsencrypt, letsencrypt-staging, zerossl, google, buypass, buypass-staging, sslcom')
3131
->addOption('storage', 's', InputOption::VALUE_REQUIRED, 'Directory to store certificates and account keys', './certs')
3232
->addOption('days', null, InputOption::VALUE_REQUIRED, 'Days before expiry to trigger renewal', '30')
3333
->addOption('key-type', null, InputOption::VALUE_REQUIRED, 'Certificate key type: ec256, ec384, rsa2048, rsa4096', 'ec256')
@@ -57,6 +57,12 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5757
return Command::FAILURE;
5858
}
5959

60+
if ($provider === null) {
61+
$this->renderError('--provider is required. Supported: letsencrypt, letsencrypt-staging, zerossl, google, buypass, buypass-staging, sslcom.');
62+
63+
return Command::FAILURE;
64+
}
65+
6066
try {
6167
$acmeProvider = ProviderResolver::resolve(
6268
$provider,

tests/Unit/Console/Command/IssueCommandTest.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ function runIssue(array $input): array
5151
expect($output)->toContain('--webroot is required');
5252
});
5353

54+
it('fails when --provider is not provided', function () {
55+
[$code, $output] = runIssue([
56+
'--domain' => ['example.com'],
57+
'--webroot' => '/tmp',
58+
]);
59+
60+
expect($code)->toBe(Command::FAILURE);
61+
expect($output)->toContain('--provider is required');
62+
});
63+
5464
it('fails for an unknown --provider', function () {
5565
[$code, $output] = runIssue([
5666
'--domain' => ['example.com'],
@@ -66,6 +76,7 @@ function runIssue(array $input): array
6676
[$code, $output] = runIssue([
6777
'--domain' => ['example.com'],
6878
'--webroot' => '/tmp',
79+
'--provider' => 'letsencrypt',
6980
'--key-type' => 'rsa9999',
7081
]);
7182

@@ -142,9 +153,10 @@ function runStub(mixed $result, array $input = []): array
142153
{
143154
$tester = new CommandTester(new StubIssueCommand($result));
144155
$tester->execute(array_merge([
145-
'--domain' => ['example.com'],
146-
'--webroot' => '/tmp',
147-
'--storage' => sys_get_temp_dir(),
156+
'--domain' => ['example.com'],
157+
'--webroot' => '/tmp',
158+
'--storage' => sys_get_temp_dir(),
159+
'--provider' => 'letsencrypt',
148160
], $input));
149161

150162
return [$tester->getStatusCode(), test()->buffer->fetch()];

0 commit comments

Comments
 (0)