From b9cb3546421402391aeb0d6c997cda481feae550 Mon Sep 17 00:00:00 2001 From: David Hook Date: Sun, 12 Jan 2025 07:41:39 +1100 Subject: [PATCH] adjusted test for expired certificate. --- .../bouncycastle/mail/smime/test/SMIMEToolkitTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/mail/src/test/java/org/bouncycastle/mail/smime/test/SMIMEToolkitTest.java b/mail/src/test/java/org/bouncycastle/mail/smime/test/SMIMEToolkitTest.java index 4d6c013104..54cb4b9c8a 100644 --- a/mail/src/test/java/org/bouncycastle/mail/smime/test/SMIMEToolkitTest.java +++ b/mail/src/test/java/org/bouncycastle/mail/smime/test/SMIMEToolkitTest.java @@ -44,6 +44,7 @@ import org.bouncycastle.mail.smime.SMIMESigned; import org.bouncycastle.mail.smime.SMIMESignedGenerator; import org.bouncycastle.mail.smime.SMIMEToolkit; +import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter; import org.bouncycastle.openssl.jcajce.JcaPKIXIdentityBuilder; import org.bouncycastle.operator.OperatorCreationException; import org.bouncycastle.operator.bc.BcDigestCalculatorProvider; @@ -261,12 +262,14 @@ public void testSignedMessageVerificationEncapsulatedWithPKIXIdentity() MimeBodyPart res = gen.generateEncapsulated(msg); - Assert.assertTrue(toolkit.isValidSignature(res, new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(identity.getCertificate()))); + // TODO: certificate has expired + JcaPEMKeyConverter keyConverter = new JcaPEMKeyConverter(); + Assert.assertTrue(toolkit.isValidSignature(res, new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(keyConverter.getPublicKey(identity.getCertificate().getSubjectPublicKeyInfo())))); MimeMessage body = makeMimeMessage(res); - Assert.assertTrue(toolkit.isValidSignature(body, new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(identity.getCertificate()))); - Assert.assertTrue(toolkit.isValidSignature(body, new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(identity.getX509Certificate()))); + Assert.assertTrue(toolkit.isValidSignature(body, new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(keyConverter.getPublicKey(identity.getCertificate().getSubjectPublicKeyInfo())))); + Assert.assertTrue(toolkit.isValidSignature(body, new JcaSimpleSignerInfoVerifierBuilder().setProvider(BC).build(identity.getX509Certificate().getPublicKey()))); } public void testEncryptedMimeBodyPart()