-
Notifications
You must be signed in to change notification settings - Fork 29
Allow peer verification for command transports #1284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,8 +8,11 @@ | |
| use Icinga\Module\Icingadb\Command\Transport\CommandTransport; | ||
| use Icinga\Module\Icingadb\Command\Transport\CommandTransportException; | ||
| use Icinga\Web\Session; | ||
| use ipl\Validator\CallbackValidator; | ||
| use ipl\Validator\X509CertValidator; | ||
| use ipl\Web\Common\CsrfCounterMeasure; | ||
| use ipl\Web\Compat\CompatForm; | ||
| use Throwable; | ||
|
|
||
| class ApiTransportForm extends CompatForm | ||
| { | ||
|
|
@@ -34,6 +37,41 @@ protected function assemble() | |
| 'description' => t('Hostname or address of the Icinga master') | ||
| ]); | ||
|
|
||
| $this->addElement('text', 'caPath', [ | ||
| 'required' => false, | ||
| 'label' => t('Verify Peer'), | ||
| 'description' => t('Path to a certificate file to verify the Icinga master\'s api certificate'), | ||
| 'placeholder' => t('Leave empty to disable peer verification'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would result in an "insecure by default" workflow, unlike other SSL/TLS UIs, such as the Redis UI. One neat idea would to allow some TOFU logic, storing the remote CA for the first connection.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redis is insecure by default? You have to toggle TLS. My gut feeling about the "TOFU logic" is that no-one expects Icinga Web to do such a thing, doesn't care and then wonders why something does not work anymore they never ever configured. Not saying that's bad, that's just not something Icinga offers in general.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yes. But if you enable TLS, validation is enforced, as specified. However, the Icinga 2 API is TLS-only. Thus, I would argue it is "secure by default", unless you deliberately choose to misconfigure your TLS client. But if a configuration nudges a user to disable validation, then this would be, IMHO, an improper certificate validation (CWE-295) just with extra steps. Edit: Your concerns about the TOFU logic seems valid. I just that this would ease setting this up.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, problem is, it'd be a breaking change. Everyone upgrading won't be able to send any commands. Is this really that critical to risk setting up users?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, when upgrading, the setup did no prior validation, so one can argue that there is no reason to change this. However, for new setups, starting with actually checking certificates would be nice. |
||
| 'validators' => [new CallbackValidator(function (?string $value, CallbackValidator $validator) { | ||
| if (empty($value)) { | ||
| return true; | ||
| } | ||
|
|
||
| if (! file_exists($value) || ! is_readable($value)) { | ||
| $validator->addMessage(t('The specified certificate file does not exist or is not readable')); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| try { | ||
| $cert = file_get_contents($value); | ||
| } catch (Throwable $e) { | ||
| $validator->addMessage(t('Failed to read certificate file: %s', $e->getMessage())); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| $x509Validator = new X509CertValidator(); | ||
| if (! $x509Validator->isValid($cert)) { | ||
| $validator->addMessages($x509Validator->getMessages()); | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
| })] | ||
| ]); | ||
|
|
||
| // TODO: Don't rely only on browser validation | ||
| $this->addElement('number', 'port', [ | ||
| 'required' => true, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not a CA file, it's a CA certificate, but then I figured it must not only be a certificate authority's certificate, but the peer's certificate. So any certificate, which is why I dropped CA from the description.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough. I just wanted the CA to be mentioned here as otherwise users would be confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused? By leaving it open for interpretation what actually is required? Don't users then use what they're familiar with and that's the CA's certificate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would imply that all users are familiar with their setup..
Furthermore, the certificate might be renewed automatically by Icinga 2. The CA, however, is static. Thus, for most setups, the Icinga 2 CA should be preferred.