1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2025-09-09 10:19:39 +02:00

SOP certify-userid: Properly throw KeyCannotCertify exception

This commit is contained in:
Paul Schaub 2025-04-10 15:26:59 +02:00
parent d540febc7f
commit b7dedbd619
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -9,6 +9,7 @@ import java.io.OutputStream
import org.bouncycastle.bcpg.PacketFormat
import org.bouncycastle.openpgp.api.OpenPGPKey
import org.pgpainless.PGPainless
import org.pgpainless.exception.KeyException
import org.pgpainless.util.ArmoredOutputStreamFactory
import org.pgpainless.util.Passphrase
import sop.Ready
@ -45,12 +46,16 @@ class CertifyUserIdImpl(private val api: PGPainless) : CertifyUserId {
var certificate = cert
keys.forEach { key ->
userIds.forEach { userId ->
certificate =
api.generateCertification()
.certifyUserId(userId, certificate)
.withKey(key, protector)
.build()
.certifiedCertificate
try {
certificate =
api.generateCertification()
.certifyUserId(userId, certificate)
.withKey(key, protector)
.build()
.certifiedCertificate
} catch (e: KeyException) {
throw SOPGPException.KeyCannotCertify(e)
}
}
}