Use public key fingerprint as S/MIME Certificate id #3570#3575
Use public key fingerprint as S/MIME Certificate id #3570#3575
Conversation
|
I guess we need to add migration correcting the fingerprints applied by PR #3445? |
tomholub
left a comment
There was a problem hiding this comment.
Looks great, thanks! I'm conflicted on whether this one needs a migration or not - S/MIME is a minor usecase for now. But to be prudent, it would be better to migrate (can be done in single step - users won't have many S/MIME keys). Also, migration errors can be ignored.
|
Or maybe, we could enumerate exactly what the side effects would be if we completely skipped migration. If the side effects are an inconvenience to user, but not a security problem, then we may skip. If security problem is implied, then we should migrate. |
Side effects... not too many, but... I'm trying to imagine some situations. |
|
I'll let you decide - I don't want to stop you from doing migration now and then causing you headaches later when we bump into it. We can afford to do it properly now and be sure. This would look like we also have longid collisions (between same-key OpenPGP and S/MIME certs)? There is no such thing as longids in S/MIME, unless I'm wrong. When an S/MIME message is encrypted or signed, does the encoded data contain information about which key it's encrypted for, and which key signed it? If so, how is this information encoded in s/mime? This is really what we need longids for in OpenPGP, else we would have dropped them. This information is encoded in OpenPGP as longids of the appropriate keys in the encrypted message packets. |
Yes, looking at https://tools.ietf.org/html/rfc2315 it turns out, that the pair <Issuer Name, SerialNumber> is used to identify the certificate for signature verification, so we may want to store it in As I can see, |
|
Should we check the certification chain when importing a certificate? If not, this |
I had the same thought. We don't currently verify the certificate chain, and the extension is not well set up for it either. Eventually, we probably will.
Also interesting - we'd have to implement it in the future.
We could indeed do that. It wouldn't even need to be hashed - nothing stops us from storing As you say, that would mean when we search by such longid, we may get back more than one result. Once we actually can handle verifying s/mime message signatures, we could refuse to verify and show gray color signature with text "conflicting s/mime certificates found". After that, once we implement verifying the chain, we can choose whichever first key that has valid chain. Therefore, right now a Then we just need to put an appropriate comments next to longid property to talk about what we store there for S/MIME. |
Issuer Name consists of attributes, that is, pairs of OID -> Value. Interestingly, the order of the fields is important for |
|
Understood, and agreed. Please see what others do, so that our approach is not too exotic :) |
|
I added a test to actually search for a certificate based on the data from PKCS#7 message (IssuerAndSerialNumber) and it succeeded. However, in some parts of the app it is assumed that "longid" can be derived from the "fingerprint" and we're currently using a different scheme for X.509 certificates. So we either have to refactor the code (especially |
|
For example, we can have |
I hope there would not be too many of such places. I think they could be refactored away? (always derive longid from whole key instead of from fingerprint) If they cannot be refactored, then we could do something like what you said. |
|
Am I getting it right, that X.509 certificates with private keys (PFX) will also be stored in AcctStore?
|
Yes, soon we will also store these
What would you rename it to?
It's ok if for now it only supports OpenPGP, for now. Once we start supporting verifying S/MIME signatures, we'll have to fix it.
Ah - I guess here we used to go by longid, then we changed to flexible fingerprint OR longid, with the plan to eventually stop supporting going by longid, which we could indeed do soon. |
|
|
Got it, can rename |
|
|
||
| try { | ||
| db = await ContactStore.dbOpen(); // takes 4-10 ms first time | ||
| await updateX509FingerprintsAndLongids(db); |
There was a problem hiding this comment.
A small nitpick - maybe this migration updateX509FingerprintsAndLongids should be done after moveContactsToEmailsAndPubkeys is already migrated? (switch line order)
There was a problem hiding this comment.
The contacts migration moveContactsToEmailsAndPubkeys sets correct fingerprints and longids, we only need to fix contacts migrated by the previous version
| if (KeyUtil.getKeyType(pubkey.armoredKey) !== 'x509') { | ||
| next(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
This is interesting - could we instead filter when pulling pubkeys from storage? Eg SELECT FROM pubkey WHERE type = 'x509'. Or we don't store this info?
There was a problem hiding this comment.
We don't store this info yet, only in ids (fingerprints) -- postfixed with "-X509", and in longids -- prefixed with "X509-"
|
I'll merge this anyway - please let me know your thoughts for the above comments afterwards. |
This PR uses public key fingerprint for S/MIME Certificate
id,postfixed with "-X509" internally.
close #3570
close #3559
Tests (delete all except exactly one):
To be filled by reviewers
I have reviewed that this PR... (tick whichever items you personally focused on during this review):