Page MenuHome GnuPG

Kleopatra: Offer retry of S/MIME encryption if encryption failed with "not trusted"
Open, HighPublic

Description

When an error occurs during S/MIME file encryption the user should be offered a yes / no message box, which indicates that we can lower the security checks. Make it non VS-NfD compliant (in VS-NfD) mode and try again to encrypt with: GPGME_ENCRYPT_ALWAYS_TRUST.

Event Timeline

aheinecke raised the priority of this task from Normal to High.Oct 13 2023, 9:56 AM

We just realized that similar to what we had in GpgOL ( https://dev.gnupg.org/T6701 ) that AlwaysTrust is used by default. And this will now result in the behavior which I also mentioned in our meeting that without question it encrypts to any S/MIME certificate. Without any warning that it is not VS-NfD compliant to do so.
This must be fixed because otherwise we show an operation as VS-NfD compliant, e.g. to encrypt to a certificate with a broken CRL. Which is not VS-NfD compliant because the CRL check was not done.

So where encrypt jobs are used we need to check for the protocol and first try to encrypt to S/MIME without ALWAYS_TRUST because otherwise the operation will always go through.

For testing with file encryption and notepad you can use this chain which is valid but does not provide a valid CRL for us

just please do not send mails to this certificate.

aheinecke lowered the priority of this task from High to Normal.Oct 13 2023, 11:23 AM

Ok. Both notepad and file encryption now again produce errors as expected. So the new override would just be a new feature and no longer a regression.

We should probably also check KMail though. There might be a similar fix needed although there I am unsure if the old keyresolver does not do a crl check when a certificate is selected.

We should probably also check KMail though. There might be a similar fix needed although there I am unsure if the old keyresolver does not do a crl check when a certificate is selected.

Not sure about S/MIME, but for OpenPGP I'm pretty sure that a check is done when a certificate is selected in the old approval dialog (resp. in the key chooser opened from this dialog).

timegrid edited projects, added Feature Request, vsd34; removed Restricted Project.Jan 23 2026, 11:17 AM
timegrid added a subscriber: timegrid.

We need to test the current state

timegrid changed the task status from Open to Testing.Jan 23 2026, 11:17 AM
timegrid moved this task from Backlog to QA on the vsd34 board.
werner raised the priority of this task from Normal to High.Wed, Mar 18, 11:23 AM
werner changed the task status from Testing to Open.Wed, Mar 18, 11:25 AM
werner moved this task from QA to Backlog on the vsd34 board.
werner added a subscriber: werner.

It is clearly not implemented for S/MIME: rKLEOPATRA9eed4a45ed93 but it should be.

ikloecker mentioned this in Unknown Object (Maniphest Task).Mon, Mar 23, 8:53 AM

Do we have a test certificate for this? The certificate in T6702#176845 is expired.

ikloecker added a project: gpd5x.
ikloecker moved this task from Backlog to WIP on the gpd5x board.

It needs to be clarified which kind of errors should be handled and which kind of S/MIME certificates should be allowed to be used for encryption:

  • Valid certificates where the CRL check (or OCSP check?) fails
  • Invalid certificates (e.g. because of incomplete chain/missing CA)
  • Expired certificates

Currently, Kleopatra doesn't even allow to start/attempt encryption for certificates which are not valid. Allowing invalid or expired certificates will require massive changes.

Maybe those smime certs will do:

  • broken: inaccessible url crlDistributionPoints = URI:http://gnupg.test/crl.pem

  • invalid: invalid content crlDistributionPoints = URI:https://gnupg.com/share/g10code-key.asc

In my tests, both have the same behavior:

  • invalid after opening the details, so the cert can't be chosen for file encryption afterwards
  • if chosen before invalidation, it hangs indefinitely on file encryption (will create another ticket for this)

According to Werner, that should be:

It needs to be clarified which kind of errors should be handled and which kind of S/MIME certificates should be allowed to be used for encryption:

  • Valid certificates where the CRL check (or OCSP check?) fails
  • Invalid certificates (e.g. because of incomplete chain/missing CA)
  • Expired certificates
ikloecker moved this task from WIP to Backlog on the gpd5x board.

@ebo and me talked about this and T6701: GpgOL: Use GPGME_ENCRYPT_ALWAYS_TRUST. We think, it's best to have a short meeting to discuss further changes.

There are currently two issues here (for both GpgOL and Kleopatra), which might have been mixed:

  1. Handling of errors (=broken CRL check for smime certs) with an easy way to "process anyway" (the original main issue of this ticket)
  2. A general wish to force the encryption for certain disallowed smime and pgp certs (expired, invalid, etc) (most important usecase: sending mails / encrypting files to recipients with temporarily expired cert or missing intermediate/root certs)

Issue 1)

  • was implemented in GpgOL
  • should still be implemented in Kleopatra in the same way it works in GpgOL (on CRL error: Dialog to retry with lower security checks = force flag)

Issue 2) should be a new ticket and needs to be specified

  • current state of offered certs in
    • GpgOL (security dialog)
      • "sign as": expired/revoked/disabled not offered, invalid forbidden
      • "encrypt to": all offered, invalid/disabled/expired/revoked forbidden (ok button disabled)
    • Kleopatra (tested with sign/encrypt file, probably the same for notepad/etc)
      • all offered (tedious, but possible via "show certificate list"), invalid/disabled/expired/revoked forbidden (OK button disabled)
  • to enable a "process anyway (i know, what i'm doing)" workflow in both Kleopatra/GpgOL, i suggest
    • on forbidden certs (probably only invalid/expired/disabled, not revoked?) add a checkbox ~"lower security" (with more explanation in the tooltip) next to the disabled OK button, which reenables the OK button and adds the "force" flag (also possible for pgp?)
    • maybe an additional warning/confirmation dialog, if the checkbox was checked
    • add a registry setting to disable this checkbox (as some admins might not want to enable their users to do this)
    • Kleopatra
      • maybe readd those forbidden certs to the default dropdown list (or keep that way as incentive to fix the problem)
      • maybe only add the checkbox for smime certs, if that's easier (as pgp certs can be easily extended)
    • GpgOL
      • add the forbidden certs to "sign as" as well (probably the sender also wants to force this temporarily)
      • ensure, that the security dialog is shown, if a forbidden cert is chosen (probably already works that way?)

Issue 1) should be implemented as already described (on error -> dialog to retry with "always trust" flag)

Issue 2) moved to new issue T8193: Add a workflow to force encryption/signature with invalid or expired certificates

ikloecker mentioned this in Unknown Object (Maniphest Task).Mon, Mar 30, 9:43 AM
ikloecker renamed this task from Kleopatra: Use GPGME_ENCRYPT_ALWAYS_TRUST to Kleopatra: Offer retry of S/MIME encryption if encryption failed with "not trusted".Mon, Mar 30, 11:38 AM
ikloecker moved this task from Backlog to WIP on the gpd5x board.

Current implementation for the case of an S/MIME certificate which turns out to be invalid when it's used for encryption. Is that what we want?

Possible improvements:

  • The "Encrypt Notepad (Not VS-NfD Compliant)" button should probably be red like the action button of the notepad if an invalid certificate is selected.
  • Show better error than "unknown host", i.e. something like "CRL check failed" or "Certificate validity check failed", but I'm not sure we get better information from gpgsm.

Feel free to suggest better texts, etc.

yes, basically it's what we want.

But the error message is really, really awful. From your suggestions I'd prefer the first one, "CRL check failed".
Maybe @pl13 can have a look at what info gpgsm can give us?

Regarding the button: yes, red for consistency would be good.
And shouldn't the certificate change from green check mark to red X after the CRL check, too? Or maybe now a blue ! because we now allow the encryption with caveats?

Ideally the certificate would change, but Kleopatra has no idea that this certificate turned out to be not valid. In fact, Kleopatra doesn't even know that the encryption failed because of some certificate. It could have failed for any other reason (e.g. full disk). Kleopatra only knows that an error occurred and offers to retry with lower security. (I looked at GpgOL and it does the same.)

Hmm, maybe Kleopatra could get some info from the encryption result. It seems to have a list of invalid recipients.

I tried to add the list of invalid recipients to the message box, but it seems that gpgsm stops the validation of the certificates at the first invalid recipient. I got only the first Bob certificate reported as invalid recipient when I tried to encrypt to both Bob certificates so that it doesn't make sense to list the (incomplete) list of invalid recipients. It also means that Kleopatra cannot update the invalid recipient certificates because it knows only of one invalid certificate.

We could validate the recipient certificates the user has chosen in the background (before they click "Encrypt"), but that's a different story.

The best option seems to be to replace the first line with the not-very-helpful error message with something like this: "Failed to encrypt the notepad because some certificates could not be validated."

Your suggestion sounds ok to me, maybe with a slight change for the message: "Failed to encrypt the notepad because at least on certificate could not be validated."

Do I understand it correctly that you found out how you can get the info that validation failed? So that you can in fact differentiate between invalid certificate and e.g. full disk?

Maybe. EncryptionResult has a list of invalid recipients and I've changed the code to show the Retry dialog only if there's at least one invalid recipient.

ikloecker mentioned this in Unknown Object (Maniphest Task).Mon, Apr 13, 9:40 AM