cacerts - support individual file per CA, more flexible filtering#21
Conversation
|
I'd like to somehow specify that |
f9b47cf to
47f8e6c
Compare
I'd be inclined to first investigate whether it's possible to make usage more simple by just removing the conflict. For example:
|
Would it not be simpler to avoid special handling for the root CA filename and just have: |
|
So I think the whole idea of output a single sorted chain of CA certificates is not always as simple as it might look at first.
Sorting in this way could give incorrect results if there were two CA certificates with the same NotBefore date in the chain - this is probably unlikely, but not impossible as far as I can tell. If we wanted to ensure the correct order of a single chain, we'd at a minimum need to make sure each certificate in the constructed chain cryptographically verifies the next one, I'd think. Moreover, RFC 5272 section 4.1 states (emphasis added):
so it's possible that there is more than one valid chain and more than one valid root CA in the returned certificates (if one of the CAs is cross-signed, for example), and in those cases assuming we have a single chain is going to lead to incorrect results (even if they all have distinct NotBefore dates). The current (It's not clear what position RFC 7030 takes on this, if any, by the way - section 4.1.3 says the Finally, RFC 7030 section 4.1.3 states:
In this case, there will be at least two root CAs (i.e. OldWithOld and NewWithNew) and at least one "intermediate" CA which will not appear in any valid certificate chain (i.e. "OldWithNew"). All this means that splitting up the CA certificates can be more complicated that it may at first look, and this is one reason why the current implementation just passes through the list of certificates as received from the EST server, letting the caller decide how it wants to handle those potential complications since this is a general-purpose EST client (although correctly handling and extracting the three "Root CA Key Update" certificates is definitely a potential future enhancement). So, if we wanted to implement the proposal, we'd have to decide how to handle these complications, for example:
If we had an actual EST-issued certificate to verify, then dumping all the CA certificates into an So I'm open to suggestions, but I think the current proposal doesn't sufficiently address these complications. |
That's what I've implemented initially, but I didn't like it.
It probably would (although not by much; and we still have to make sure that the root goes first). |
I didn't mean to sort it in any meaningful way (I don't think the order really matters anywhere) - only to provide stability (i.e. that between invocations of So, from what I understand, what we can do to greatly simplify things - is to use the filename format that you've proposed, which doesn't distinguish between root and intermediate CAs, i.e. |
|
I was looking for clarification regarding the order of certificates: RFC 7030, 4.1.3. CA Certificates Response:
RFC 5272, 4.1. Simple PKI Response:
So according to RFC 5272 the order is insignificant and clients should be able to handle that. |
|
What do you think about the following?
|
Correct - nothing specific is currently done with them, although if present they'll be included in the returned set of CA certs. |
I'm hesitant at this kind of scheme because I think there are about as many different potential naming/grouping schemes as there are potential users, and for a general purpose EST client I'd rather users be able to choose their own way than us impose a way on them. I think adding an index is the most structure we'd want to impose, here. How about this as a more general solution:
and in all cases the order is not guaranteed, other than to be in the same relative order that they were received from the server. (We can also apply these two flags to the situation where With this scheme, prefix-1.pem could be a root CA when run with the would yield
I get your point but I'm not too troubled by this. I think a case can be made in the other way, e.g. output usually goes to standard out if |
|
I understand that you are concerned that we are enforcing/limiting something, but I would argue that:
Anyway, I am on board with your proposal to have Ok, by items:
|
Let's reuse
Since we're always going to be outputting PEM-encoded certificates here, I think we should allow that extension, but not require it. If the prefix ends with ".pem" (case-insensitive) then remove those four characters and the prefix is what remains. In all other cases, the prefix is the entire string specified by
By packaging the behavior up into testable functions and having the |
47f8e6c to
7f78a1a
Compare
|
I've updated the PR with new implementation. Note, that I've changed the criteria for a 'root' certificate (as noted in commit msg). Please share your thoughts. |
I don't agree with this change - a root certificate is one which can form the root of a chain of trust (i.e. which can begin a certification path), and which is therefore directly trusted without requiring any additional cryptographic verification, i.e.:
per RFC 5280 section 3.2, and:
per RFC 4210 section 4.4. In terms of the "Root CA Key Update" procedure as defined in Section 4.4 of RFC 4210, both "new with old" and "old with new" by definition require at least one other certificate earlier in the certification path, and therefore they are not root certificates. They are both self-issued certificates which "are generated to support changes in policy or operations" per RFC 5280, but self-signed, root certificates are still required in order to trust and use them. The remaining certificates (i.e. "old with old" and "new with new") are self-signed and fall under the existing definition of 'root'. In general, an issue should be opened for any proposed changes of this nature, so that they can be properly discussed and decided upon before anyone spends time implementing them, and because PRs become more difficult and time-consuming to process when they contain other, non-essential changes. |
I have no problem with revering this (it really didn't deserve that much text :) ). |
This implements filtering of CA certificates - using one of `roots` or `intermediates` flags allows the user to output only root or intermediate CA certificates respectively. In contrast with `rootout` flag, `roots` flag also supports outputting multiple root certificates. `rootout` flag is now deprecated and will be removed in favor of `roots` in the future. Signed-off-by: Ievgen Popovych <ievgenp@seetrue.ai>
It is often required to have every CA certificate in its own file, so instead of splitting them manually (which is clunky) - provide this option. A new flag, `separate`, enables this mode. It is possible to set filename prefix with `out` flag. Files are written in a format `<prefix>-<index>.pem`, `ca` is the default prefix, prefix can also end with `.pem`.
7f78a1a to
0485542
Compare
|
Fixed all comments:
P.S. I hope you're OK with me force-pushing (GitHub doesn't make it nice)... |
|
Oh, that happened fast.. :) |
Yes, good point, the use of |
…dual-file-per-ca cacerts - support individual file per CA, more flexible filtering
This implements two features - more flexible output filtering and
writing CA certs to individual files.
Flexible output filtering
Using one of
rootsorintermediatesflags allows the user to outputonly root or intermediate CA certificates respectively.
In contrast with
rootoutflag,rootsflag also supports outputting multiple root certificates.Writing every CA cert to separate file:
A new flag,
separate, enables this mode.It is possible to set filename prefix with
outflag.Files are written in a format
<prefix>-<index>.pem,cais the default prefix, prefix can also end with.pem.TODO: