diff --git a/core/src/test/kotlin/net/corda/core/JarSignatureTestUtils.kt b/core/src/test/kotlin/net/corda/core/JarSignatureTestUtils.kt index d5d9bed118..273d5b2234 100644 --- a/core/src/test/kotlin/net/corda/core/JarSignatureTestUtils.kt +++ b/core/src/test/kotlin/net/corda/core/JarSignatureTestUtils.kt @@ -25,8 +25,8 @@ object JarSignatureTestUtils { .waitFor()) } - fun Path.generateKey(alias: String, password: String, name: String) = - executeProcess("keytool", "-genkey", "-keystore", "_teststore", "-storepass", "storepass", "-keyalg", "RSA", "-alias", alias, "-keypass", password, "-dname", name) + fun Path.generateKey(alias: String, password: String, name: String, keyalg: String = "RSA") = + executeProcess("keytool", "-genkey", "-keystore", "_teststore", "-storepass", "storepass", "-keyalg", keyalg, "-alias", alias, "-keypass", password, "-dname", name) fun Path.createJar(fileName: String, vararg contents: String) = executeProcess(*(arrayOf("jar", "cvf", fileName) + contents)) diff --git a/core/src/test/kotlin/net/corda/core/internal/JarSignatureCollectorTest.kt b/core/src/test/kotlin/net/corda/core/internal/JarSignatureCollectorTest.kt index 1a379a9f09..4c124e81b7 100644 --- a/core/src/test/kotlin/net/corda/core/internal/JarSignatureCollectorTest.kt +++ b/core/src/test/kotlin/net/corda/core/internal/JarSignatureCollectorTest.kt @@ -8,6 +8,7 @@ import net.corda.core.JarSignatureTestUtils.updateJar import net.corda.core.identity.Party import net.corda.testing.core.ALICE_NAME import net.corda.testing.core.BOB_NAME +import net.corda.testing.core.CHARLIE_NAME import org.assertj.core.api.Assertions.assertThat import org.junit.After import org.junit.AfterClass @@ -129,6 +130,16 @@ class JarSignatureCollectorTest { assertFailsWith { dir.getJarSigners(FILENAME) } } + // Signing with EC algorithm produces META-INF/*.EC file name not compatible with JAR File Spec however it's compatible with java.util.JarVerifier + // and our JarSignatureCollector + @Test + fun `one signer with EC algorithm`() { + dir.generateKey(CHARLIE, CHARLIE_PASS, CHARLIE_NAME.toString(), "EC") + dir.createJar(FILENAME, "_signable1", "_signable2") + val key = dir.signJar(FILENAME, CHARLIE, CHARLIE_PASS) + assertEquals(listOf(key), dir.getJarSigners(FILENAME)) // We only used CHARLIE's distinguished name, so the keys will be different. + } + private fun signAsAlice() = dir.signJar(FILENAME, ALICE, ALICE_PASS) private fun signAsBob() = dir.signJar(FILENAME, BOB, BOB_PASS) }