You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My knowledge on this is limited, but I think it should already work with multiple recipients, if their keys were signed with a shared CA certificate. Or something like that.
Sorry for delay to answer.
To encrypt mail for multiple recipients, you have to encrypt it with each recipient certificate (public key), then, they will be able to decrypt the mail on their side with their private key.
I'll will try to work with you on this !
At one of the companies I worked, they configured a single (CA?) cert, which was used to sign (encrypt?) all emails without needing recipients individual public keys. Is your use case actually really a common one? Seems like a hassle!
Usually, a company has its own CA, they use it to sign internal certificates. Each employee then has a key pair (private and public key).
Let's say I want to send an encrypted mail to Alice and I want her to be the only one to be able to decrypt it. I encrypt it with her public key. The only person able to decrypt the sent mail is the one with the corresponding private key (=Alice).
Now, I want to send an encrypted mail to Alice and Bob (at the same time, = multiple recipients). If I encrypt it only with Alice public key, only Alice will be able to read it. Bob can't. That's why I need to encrypt it twice : one time with Alice's public key, one time with Bob's one.
Right now, if I want to do that with simple-java-mail, I have to send 2 distincts emails instead of one.
I don't know the company you're talking about but if you use only one certificate (you usually don't use a CA for that) to encrypt each email, that means, everybody share the private key and everybody can decrypt them.
The same if everybody use the same key to sign each email, you can't be sure of who really send it. Usually, you sign it with your private key.
But maybe that's what they intended to do...
By the way, in the lib, sign case is ok because you always sign a mail once (= with one private key).
By the way, in the lib, sign case is ok because you always sign a mail once (= with one private key).
Ahh then that might have been the case at the company I worked for at the time.
You made a convincing case, one question: this change would mean being able to sign on a per-email basis (so using EmailBuilder). Would it ever make sense to be able to do it on Mailer level as well, affecting all emails that don't have their own key added for signing/encrypting?
Not sure to understand your question: "do it on Mailer level... emails that don't have their own key added for signing/encrypting"
As encryption is for a specific recipient, I think certificates has to be done explicitely set in emailBuilder (no default value). For signing, it can be configured as default (as you can choose to sign all your email).
bbottema, the documentation you reference to RecipientBuilder looks great. I have version 8.12.4 but I don't see RecipientBuilder in the jar. I also have the SMIME module and the core module and I don't see it listed anywhere. Am I looking in the wrong place? How should I get this functionality? Thanks!
bbottema, I've got the 8.12.5 version of simplejavamail and I don't see the RecipientBuilder changes in it. Do you plan to create a release with RecipientBuilder, etc? Thanks.
I think I've made a mistake with the documentation, it should have been in a separate (unreleased) branch. Sorry for the confusion.
I intend to pick this up again, but I'm currently on a break from the library. I've been developing it for almost 19 years now, and every now and then I take a long break (6-12 months) before diving back in. Unfortunately, I can't tell when I'm going to pick it up again, sorry. I have a lot going on right now.
Fixed by making S/MIME encryption certificate selection recipient-aware.
A Recipient can now carry its own X509Certificate via RecipientBuilder.withSmimeCertificate(...). When any TO/CC/BCC recipient has a certificate, Simple Java Mail uses the per-recipient encryption path; recipient-level certificates override the email-level default, while the email-level SmimeEncryptionConfig can still provide fallback certificates and algorithms.
Activity
bbottema commentedon Dec 15, 2020
My knowledge on this is limited, but I think it should already work with multiple recipients, if their keys were signed with a shared CA certificate. Or something like that.
nathinthesky commentedon Apr 2, 2021
Sorry for delay to answer.
To encrypt mail for multiple recipients, you have to encrypt it with each recipient certificate (public key), then, they will be able to decrypt the mail on their side with their private key.
I'll will try to work with you on this !
bbottema commentedon Apr 10, 2021
At one of the companies I worked, they configured a single (CA?) cert, which was used to sign (encrypt?) all emails without needing recipients individual public keys. Is your use case actually really a common one? Seems like a hassle!
nathinthesky commentedon Apr 19, 2021
I think my case is a common one.
Usually, a company has its own CA, they use it to sign internal certificates. Each employee then has a key pair (private and public key).
Let's say I want to send an encrypted mail to Alice and I want her to be the only one to be able to decrypt it. I encrypt it with her public key. The only person able to decrypt the sent mail is the one with the corresponding private key (=Alice).
Now, I want to send an encrypted mail to Alice and Bob (at the same time, = multiple recipients). If I encrypt it only with Alice public key, only Alice will be able to read it. Bob can't. That's why I need to encrypt it twice : one time with Alice's public key, one time with Bob's one.
Right now, if I want to do that with simple-java-mail, I have to send 2 distincts emails instead of one.
I don't know the company you're talking about but if you use only one certificate (you usually don't use a CA for that) to encrypt each email, that means, everybody share the private key and everybody can decrypt them.
The same if everybody use the same key to sign each email, you can't be sure of who really send it. Usually, you sign it with your private key.
But maybe that's what they intended to do...
By the way, in the lib, sign case is ok because you always sign a mail once (= with one private key).
bbottema commentedon Apr 24, 2021
Ahh then that might have been the case at the company I worked for at the time.
You made a convincing case, one question: this change would mean being able to sign on a per-email basis (so using EmailBuilder). Would it ever make sense to be able to do it on Mailer level as well, affecting all emails that don't have their own key added for signing/encrypting?
nathinthesky commentedon Apr 27, 2021
you mean to encrypt on a per-email basis ?
Not sure to understand your question: "do it on Mailer level... emails that don't have their own key added for signing/encrypting"
As encryption is for a specific recipient, I think certificates has to be done explicitely set in emailBuilder (no default value). For signing, it can be configured as default (as you can choose to sign all your email).
bbottema commentedon Apr 29, 2021
So no use case whatsoever to allow a default. Ever. (just double checking)
8 remaining items
jgprospect commentedon Dec 26, 2024
bbottema, the documentation you reference to RecipientBuilder looks great. I have version 8.12.4 but I don't see RecipientBuilder in the jar. I also have the SMIME module and the core module and I don't see it listed anywhere. Am I looking in the wrong place? How should I get this functionality? Thanks!
jgprospect commentedon Apr 11, 2025
bbottema, I've got the 8.12.5 version of simplejavamail and I don't see the RecipientBuilder changes in it. Do you plan to create a release with RecipientBuilder, etc? Thanks.
bbottema commentedon Apr 12, 2025
I think I've made a mistake with the documentation, it should have been in a separate (unreleased) branch. Sorry for the confusion.
I intend to pick this up again, but I'm currently on a break from the library. I've been developing it for almost 19 years now, and every now and then I take a long break (6-12 months) before diving back in. Unfortunately, I can't tell when I'm going to pick it up again, sorry. I have a lot going on right now.
I do still pick up security patches.
jgprospect commentedon Apr 12, 2025
Understand.
I'll look forward to when you make those changes. Until then, I'm very happy using what you've done.
Thanks.
#297: Close gap - apply per-recipient S/MIME certificates during sending
#613 #297: Add S/MIME metadata to recipient builders
#613 #297: Update tests for recipient certificate constructor
#297 #613: Apply per-recipient S/MIME certificates when sending
#613 #297: Preserve Recipient toString compatibility
bbottema commentedon Jul 3, 2026
Fixed by making S/MIME encryption certificate selection recipient-aware.
A
Recipientcan now carry its ownX509CertificateviaRecipientBuilder.withSmimeCertificate(...). When any TO/CC/BCC recipient has a certificate, Simple Java Mail uses the per-recipient encryption path; recipient-level certificates override the email-level default, while the email-levelSmimeEncryptionConfigcan still provide fallback certificates and algorithms.Example:
For multiple recipients, build each
Recipientwith its own certificate and pass them through.to(...),.cc(...), or.bcc(...).bbottema commentedon Jul 8, 2026
Released in Simple Java Mail v9.0.0, which is now available from Maven Central:
https://repo1.maven.org/maven2/org/simplejavamail/simple-java-mail/9.0.0/
Release notes:
https://github.com/bbottema/simple-java-mail/releases/tag/9.0.0