From 96d8ec964042c0feece297ff56a7cf38778755d0 Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Tue, 12 Dec 2017 17:07:35 +0000 Subject: [PATCH] Dynamically add BouncyCastle provider (#185) --- network-management/build.gradle | 4 ++++ .../main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/network-management/build.gradle b/network-management/build.gradle index 128a31cf06..625ebb42e6 100644 --- a/network-management/build.gradle +++ b/network-management/build.gradle @@ -114,4 +114,8 @@ dependencies { //TODO remove once we can put driver jar into a predefined directory //JDBC driver can be passed to the Node at startup using setting the jarDirs property in the Node configuration file. compile 'com.microsoft.sqlserver:mssql-jdbc:6.2.1.jre8' + + // Bouncy Castle for HSM signing + compile "org.bouncycastle:bcprov-jdk15on:${bouncycastle_version}" + compile "org.bouncycastle:bcpkix-jdk15on:${bouncycastle_version}" } diff --git a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt index 153411eebb..e148e2007c 100644 --- a/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt +++ b/network-management/src/main/kotlin/com/r3/corda/networkmanage/hsm/Main.kt @@ -15,6 +15,9 @@ import com.r3.corda.networkmanage.hsm.persistence.DBSignedCertificateRequestStor import com.r3.corda.networkmanage.hsm.signer.HsmCsrSigner import com.r3.corda.networkmanage.hsm.signer.HsmNetworkMapSigner import com.r3.corda.networkmanage.hsm.utils.mapCryptoServerException +import org.bouncycastle.jce.provider.BouncyCastleProvider +import java.security.Security + fun main(args: Array) { run(parseParameters(*args)) @@ -22,6 +25,11 @@ fun main(args: Array) { fun run(parameters: Parameters) { parameters.run { + // Ensure the BouncyCastle provider is installed + if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) { + Security.addProvider(BouncyCastleProvider()) + } + // Create DB connection. checkNotNull(dataSourceProperties) val database = configureDatabase(dataSourceProperties, databaseConfig)