-
Notifications
You must be signed in to change notification settings - Fork 67
feat(daemon): mTLS support [2a/2] #708
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
Conversation
59eea14 to
a29dd07
Compare
2e731d8 to
ca29abb
Compare
2e62737 to
ba52ae9
Compare
The pairing manager enables and processes incoming mTLS client pairing
requests on the ```/v1/pairing``` HTTP end-point.
The pairing manager does not by itself decide when the pairing window
should be enabled. The ```EnablePairing``` call will be made by another
manager (called the trigger manager) that deals with event bindings,
such as mapping a button press to an enable pairing request. The trigger
manager will be added at a later stage.
This pull-request focuses only on the Pairing Manager itself,
implementing the following functionality (KO093, KO088):
```go
// PairingEnabled returns whether pairing is currently enabled.
func (m *PairingManager) PairingEnabled() bool {...}
```
```go
// EnablePairing requests the pairing manager to enable the pairing window.
func (m *PairingManager) EnablePairing(timeout time.Duration) error {...}
```
```go
// PairMTLS adds a certificate based client identity with admin permissions to
// the identity subsystem. A pairing request always closes the pairing window.
func (m *PairingManager) PairMTLS(clientCert *x509.Certificate) error {...}
```
Integration of the pairing manager into the HTTPS server and access
checks will follow in #708
ba52ae9 to
56bccf1
Compare
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.
Looks pretty good overall, however, see the note about the missing UserState.UID -- I might be missing something, but I believe this is a bug that will cause UID-based notices to not work.
|
Oh, one other thought: it would make for a smaller PR to review if the |
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.
I left a small suggestion, and commented on Ben's comment touching on crypto code. I am happy with the mTLS implementation here.
|
The client code is now split into a separate PR (#715). Note that the end-to-end test proposal will only work with both PRs in place. |
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.
Very good, thanks for the updates.
275179f to
6d79697
Compare
|
Final approval happened for 6d79697 I added another commit on top of this, and then reverted it back to this commit (I will move the unit test enhancements into a separate PR). |
|
Performed curl based final check to prove server and pairing works with mTLS. |
The client side mTLS code was split from #708. For the complete description of the work, please refer to the description in #708. Pebble client changes adds: - The ability to supply the client identity certificate, but this is not yet used by the CLI and therefore Pebble cannot use HTTPS today. - The ability to obtain the server identity certificate by making an insecure HTTPS connection. Can be used to implement an SSH-like workflow to implement a CLI warning asking the user to trust the server identity for future connections. - The ability to pair with the server by supplying the server identity fingerprint. This workflow requires obtaining the fingerprint by other means, such as DNSSD or via a display on the server side.
The daemon HTTPS server (when enabled) uses TLS v1.3 for the client server handshake.
The traditional TLS handshake does not provide us with a way to exchange identity certificates between client and server, since only the server certificate is sent to the client. This leaves the current TLS connection relying on basic authentication headers for passing a client identity to the server.
This patch migrates the HTTPS server over from basic authentication to using mutual TLS. The client (see #715) now has to supply a suitable client identity certificate that will be used for verifying the identity during normal API usage, although this requirement is not enforced for end-points with open access.
In #702 we added a pairing manager, which integrates with the daemon API permissions system to facilitate client server pairing during a carefully controlled pairing window on a dedicated API end-point
v1/pairingonly.A followup task will provide an official event binding mechanism (trigger manager) by which the pairing window can be enabled when certain events are configured. For now, this cannot be enabled and therefore pairing is not possible. The the patch below hooking in the pairing window enable for testing purposes.
State of HTTPS (mTLS) after this patch
Testing
The following test procedure can offer a demonstration how this works, but the process requires a small temporary patch to enable pairing: