Dynamically add BouncyCastle provider (#185)

This commit is contained in:
Ross Nicoll 2017-12-12 17:07:35 +00:00 committed by GitHub
parent 2725f53ef5
commit 96d8ec9640
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -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}"
}

View File

@ -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<String>) {
run(parseParameters(*args))
@ -22,6 +25,11 @@ fun main(args: Array<String>) {
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)