Repository navigation
Store x.509 certs in CRDB, auto-load on boot, API for management - #2099
Conversation
I've been committing to Omicron for a while, and even I forget all the steps involved here. I figured I'd write this down after going through the process on #2099 - maybe this could also serve as a discussion point for "are some of these steps more complicated than they need to be?".
| #[error("Certificate exists, but is empty")] | ||
| CertificateEmpty, | ||
|
|
||
| #[error("Failed to parse private key")] |
There was a problem hiding this comment.
Is there anything useful in the openssl stack here (that'd be useful to put into the error message the way we do for BadCertificate)?
There was a problem hiding this comment.
I had a request to do roughly the opposite of this in #2099 (comment) - I don't have any way to parse the openssl stack, and I haven't validated that it wouldn't leak private key info.
There was a problem hiding this comment.
Okay, we can deal with that if we run into this failure mode in the wild.
| /// server. This involves either: | ||
| /// - Creating a new HTTPS server if once does not exist | ||
| /// - Refreshing an existing HTTPS server if it already exists | ||
| /// - Tearing down an HTTPS server if no certificates exist |
There was a problem hiding this comment.
You're right -- this is harder than I thought. I was thinking that we're creating one HTTPS server for each certificate, all on the same port, but of course that makes no sense.
I didn't (and don't) have a particular answer in mind.
My intuition is that there's no good reason to allow external API requests to remove the last certificate because I can't think of a reason to do that and it seems like it would result in nobody but Oxide support being able to access the rack any more, and then likely only through the technician port. Fixing that isn't necessarily an MVP blocker or a blocker for this PR.
I also imagine operators wanting a way to test a new certificate without risk to existing end users, in which case they might need better tools for promotion/activation like you said, but I definitely wouldn't say that's an MVP thing.
| // Lookup x509 certificates which might be stored in CRDB, specifically | ||
| // for launching the Nexus service. | ||
| // | ||
| // We only grab one certificate (see: the "limit" argument) because |
There was a problem hiding this comment.
I had missed before that we're just grabbing an arbitrary one here. What do you think of using limit 2 and warning if we find more than one? That way if support is asked to debug a cert-related problem, we can see if there was more than one configured when the server went to configure its cert.
| # Oxide API: configuration file for test suite | ||
| # | ||
|
|
||
| # Avoid conflicting with other ports during HTTPS tests |
There was a problem hiding this comment.
To be more specific, I mean: why can't this use a regular dropshot config block with a bind port of 0? I guess that's because what you said that we need to know the port before the HTTPS server is running? (Does that also mean you can't use 0 in the production config here?)
This isn't that important. I ask because when the TLS server was just another item in the dropshot_external array, that meant you could adjust its config (e.g., request_body_max_bytes) the same way as anything else. With this change, the TLS server is sort of special and if we ever wanted to adjust its config, it seems like we'd have to invent an ad hoc structure for that. Again, not super important, I just figured I'd ask.
|
|
||
| /// Internal dropshot server | ||
| internal_server: Mutex<Option<DropshotServer>>, | ||
| internal_server: std::sync::Mutex<Option<DropshotServer>>, |
There was a problem hiding this comment.
Why the change to std::sync? I think for Nexus it's dangerous to use a std::sync::Mutex in async code, since the program and environment are complicated enough that it's very hard to guarantee that we'll never block for a while with the lock held (and then block the executor). (If it's because of this section of the docs, there was a discussion in oxide-rust the other day concluding that that note is a bit confusing.)
There was a problem hiding this comment.
It was requested that I make this change in #2099 (comment) ; @sunshowers , do you have strong opinions?
| /// This certificate is intended for the "Nexus" service. | ||
| /// | ||
| /// This service acts as the main API point for accessing the Oxide rack. | ||
| Nexus, |
There was a problem hiding this comment.
nit: I'd suggest we call this External or ExternalApi instead. I'm not sure operators should be aware of "Nexus", or that it's the external endpoint (it might not always be! if we add a load balancer in the future). Plus, these certs are used for only one of Nexus's servers (not the internal API).
davepacheco
left a comment
There was a problem hiding this comment.
Forgot to hit "approve". I'm cool with deferring all the items I mentioned.
/system/certificatesAPI to NexusTODO (remaining items postponed until after this PR):
/system/...endpoint this way is surprisingly difficult. There are a ton of steps to keep track of... maybe I could document or improve this process?: [docs][nexus] Document the process for adding new endpoints #2101Part of #1959