From d19eb4a9d7467f0119dfec0b91c0d187b74b0834 Mon Sep 17 00:00:00 2001 From: Shams Asari Date: Wed, 17 Jan 2018 17:47:40 +0000 Subject: [PATCH] Removed useHTTPS from NodeConfiguration as it's not needed by the node. (#2375) It's still expected to be present in node.conf if the web server needs to use SSL. --- config/dev/generalnodea.conf | 1 - config/dev/generalnodeb.conf | 1 - config/dev/nameservernode.conf | 1 - docs/source/corda-configuration-file.rst | 5 ----- docs/source/deploying-a-node.rst | 2 -- .../src/main/resources/example-network-map-node.conf | 1 - .../example-code/src/main/resources/example-node.conf | 1 - .../corda/node/services/config/NodeConfiguration.kt | 5 ----- node/src/main/resources/reference.conf | 1 - .../node/services/config/NodeConfigurationImplTest.kt | 1 - .../kotlin/net/corda/test/spring/SpringDriver.kt | 2 +- .../src/main/kotlin/net/corda/testing/driver/Driver.kt | 5 ++++- .../net/corda/testing/node/internal/DriverDSLImpl.kt | 10 +++++++--- 13 files changed, 12 insertions(+), 24 deletions(-) diff --git a/config/dev/generalnodea.conf b/config/dev/generalnodea.conf index 12a3200105..7547300ca6 100644 --- a/config/dev/generalnodea.conf +++ b/config/dev/generalnodea.conf @@ -4,4 +4,3 @@ trustStorePassword : "trustpass" p2pAddress : "localhost:10002" rpcAddress : "localhost:10003" webAddress : "localhost:10004" -useHTTPS : false diff --git a/config/dev/generalnodeb.conf b/config/dev/generalnodeb.conf index 55ebb1e690..f922e91536 100644 --- a/config/dev/generalnodeb.conf +++ b/config/dev/generalnodeb.conf @@ -4,4 +4,3 @@ trustStorePassword : "trustpass" p2pAddress : "localhost:10005" rpcAddress : "localhost:10006" webAddress : "localhost:10007" -useHTTPS : false diff --git a/config/dev/nameservernode.conf b/config/dev/nameservernode.conf index 0519e56872..3f700628dc 100644 --- a/config/dev/nameservernode.conf +++ b/config/dev/nameservernode.conf @@ -6,4 +6,3 @@ webAddress : "localhost:10001" notary : { validating : true } -useHTTPS : false diff --git a/docs/source/corda-configuration-file.rst b/docs/source/corda-configuration-file.rst index 49572d1c8e..79ce625b0d 100644 --- a/docs/source/corda-configuration-file.rst +++ b/docs/source/corda-configuration-file.rst @@ -43,7 +43,6 @@ Simple Notary configuration file. notary : { validating : false } - useHTTPS : false devMode : true compatibilityZoneURL : "https://cz.corda.net" @@ -129,10 +128,6 @@ path to the node's base directory. Only one of ``raft``, ``bftSMaRt`` or ``custom`` configuration values may be specified. -:useHTTPS: If false the node's web server will be plain HTTP. If true the node will use the same certificate and private - key from the ``/certificates/sslkeystore.jks`` file as the ArtemisMQ port for HTTPS. If HTTPS is enabled - then unencrypted HTTP traffic to the node's **webAddress** port is not supported. - :rpcUsers: A list of users who are authorised to access the RPC system. Each user in the list is a config object with the following fields: diff --git a/docs/source/deploying-a-node.rst b/docs/source/deploying-a-node.rst index 4f94c02c95..6b17b9dd5d 100644 --- a/docs/source/deploying-a-node.rst +++ b/docs/source/deploying-a-node.rst @@ -46,7 +46,6 @@ handling, and ensures the Corda service is run at boot. myLegalName : "O=Bank of Breakfast Tea, L=London, C=GB" keyStorePassword : "cordacadevpass" trustStorePassword : "trustpass" - useHTTPS : false devMode : false rpcUsers=[ { @@ -217,7 +216,6 @@ at boot, and means the Corda service stays running with no users connected to th keyStorePassword : "cordacadevpass" trustStorePassword : "trustpass" extraAdvertisedServiceIds: [ "" ] - useHTTPS : false devMode : false rpcUsers=[ { diff --git a/docs/source/example-code/src/main/resources/example-network-map-node.conf b/docs/source/example-code/src/main/resources/example-network-map-node.conf index e75807bbc7..980f5f7031 100644 --- a/docs/source/example-code/src/main/resources/example-network-map-node.conf +++ b/docs/source/example-code/src/main/resources/example-network-map-node.conf @@ -4,4 +4,3 @@ trustStorePassword : "trustpass" p2pAddress : "my-network-map:10000" webAddress : "localhost:10001" sshdAddress : "localhost:10002" -useHTTPS : false diff --git a/docs/source/example-code/src/main/resources/example-node.conf b/docs/source/example-code/src/main/resources/example-node.conf index c01a10fd78..3715ff22e8 100644 --- a/docs/source/example-code/src/main/resources/example-node.conf +++ b/docs/source/example-code/src/main/resources/example-node.conf @@ -10,7 +10,6 @@ dataSourceProperties : { p2pAddress : "my-corda-node:10002" rpcAddress : "my-corda-node:10003" webAddress : "localhost:10004" -useHTTPS : false rpcUsers : [ { username=user1, password=letmein, permissions=[ StartFlow.net.corda.protocols.CashProtocol ] } ] diff --git a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt index 8347c28d21..61a7da64ab 100644 --- a/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt +++ b/node/src/main/kotlin/net/corda/node/services/config/NodeConfiguration.kt @@ -17,8 +17,6 @@ import java.util.* val Int.MB: Long get() = this * 1024L * 1024L interface NodeConfiguration : NodeSSLConfiguration { - // myLegalName should be only used in the initial network registration, we should use the name from the certificate instead of this. - // TODO: Remove this so we don't accidentally use this identity in the code? val myLegalName: CordaX500Name val emailAddress: String val exportJMXto: String @@ -34,8 +32,6 @@ interface NodeConfiguration : NodeSSLConfiguration { val notary: NotaryConfig? val activeMQServer: ActiveMqServerConfiguration val additionalNodeInfoPollingFrequencyMsec: Long - // TODO Remove as this is only used by the driver - val useHTTPS: Boolean val p2pAddress: NetworkHostAndPort val rpcAddress: NetworkHostAndPort? val messagingServerAddress: NetworkHostAndPort? @@ -114,7 +110,6 @@ data class NodeConfigurationImpl( // TODO typesafe config supports the notion of durations. Make use of that by mapping it to java.time.Duration. // Then rename this to messageRedeliveryDelay and make it of type Duration override val messageRedeliveryDelaySeconds: Int = 30, - override val useHTTPS: Boolean, override val p2pAddress: NetworkHostAndPort, override val rpcAddress: NetworkHostAndPort?, // TODO This field is slightly redundant as p2pAddress is sufficient to hold the address of the node's MQ broker. diff --git a/node/src/main/resources/reference.conf b/node/src/main/resources/reference.conf index fe29913bca..d73f0b8ae8 100644 --- a/node/src/main/resources/reference.conf +++ b/node/src/main/resources/reference.conf @@ -14,7 +14,6 @@ database = { exportHibernateJMXStatistics = "false" } devMode = true -useHTTPS = false h2port = 0 useTestClock = false verifierType = InMemory diff --git a/node/src/test/kotlin/net/corda/node/services/config/NodeConfigurationImplTest.kt b/node/src/test/kotlin/net/corda/node/services/config/NodeConfigurationImplTest.kt index f04ca1ec4d..1b6f20fa81 100644 --- a/node/src/test/kotlin/net/corda/node/services/config/NodeConfigurationImplTest.kt +++ b/node/src/test/kotlin/net/corda/node/services/config/NodeConfigurationImplTest.kt @@ -40,7 +40,6 @@ class NodeConfigurationImplTest { dataSourceProperties = makeTestDataSourceProperties(ALICE_NAME.organisation), rpcUsers = emptyList(), verifierType = VerifierType.InMemory, - useHTTPS = false, p2pAddress = NetworkHostAndPort("localhost", 0), rpcAddress = NetworkHostAndPort("localhost", 1), messagingServerAddress = null, diff --git a/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt b/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt index c7d7a57ffd..9d83d481ba 100644 --- a/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt +++ b/samples/irs-demo/src/integration-test/kotlin/net/corda/test/spring/SpringDriver.kt @@ -71,7 +71,7 @@ data class SpringBootDriverDSL(private val driverDSL: DriverDSLImpl) : InternalD } private fun queryWebserver(handle: NodeHandle, process: Process, checkUrl: String): WebserverHandle { - val protocol = if (handle.configuration.useHTTPS) "https://" else "http://" + val protocol = if (handle.useHTTPS) "https://" else "http://" val url = URL(URL("$protocol${handle.webAddress}"), checkUrl) val client = OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(10, TimeUnit.SECONDS).build() diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt index 7866a7cb91..ad258f6f70 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/driver/Driver.kt @@ -15,8 +15,8 @@ import net.corda.node.internal.StartedNode import net.corda.node.services.config.NodeConfiguration import net.corda.node.services.config.VerifierType import net.corda.testing.DUMMY_NOTARY_NAME -import net.corda.testing.node.User import net.corda.testing.node.NotarySpec +import net.corda.testing.node.User import net.corda.testing.node.internal.DriverDSLImpl import net.corda.testing.node.internal.genericDriver import net.corda.testing.node.internal.getTimestampAsDirectoryName @@ -41,6 +41,7 @@ sealed class NodeHandle { abstract val rpc: CordaRPCOps abstract val configuration: NodeConfiguration abstract val webAddress: NetworkHostAndPort + abstract val useHTTPS: Boolean /** * Stops the referenced node. @@ -52,6 +53,7 @@ sealed class NodeHandle { override val rpc: CordaRPCOps, override val configuration: NodeConfiguration, override val webAddress: NetworkHostAndPort, + override val useHTTPS: Boolean, val debugPort: Int?, val process: Process, private val onStopCallback: () -> Unit @@ -70,6 +72,7 @@ sealed class NodeHandle { override val rpc: CordaRPCOps, override val configuration: NodeConfiguration, override val webAddress: NetworkHostAndPort, + override val useHTTPS: Boolean, val node: StartedNode, val nodeThread: Thread, private val onStopCallback: () -> Unit diff --git a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt index 24d08bc896..21182a1da3 100644 --- a/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt +++ b/testing/node-driver/src/main/kotlin/net/corda/testing/node/internal/DriverDSLImpl.kt @@ -327,7 +327,7 @@ class DriverDSLImpl( } private fun queryWebserver(handle: NodeHandle, process: Process): WebserverHandle { - val protocol = if (handle.configuration.useHTTPS) "https://" else "http://" + val protocol = if (handle.useHTTPS) "https://" else "http://" val url = URL("$protocol${handle.webAddress}/api/status") val client = OkHttpClient.Builder().connectTimeout(5, TimeUnit.SECONDS).readTimeout(60, TimeUnit.SECONDS).build() @@ -605,10 +605,14 @@ class DriverDSLImpl( val baseDirectory = config.corda.baseDirectory.createDirectories() localNetworkMap?.networkParametersCopier?.install(baseDirectory) localNetworkMap?.nodeInfosCopier?.addConfig(baseDirectory) + val onNodeExit: () -> Unit = { localNetworkMap?.nodeInfosCopier?.removeConfig(baseDirectory) countObservables.remove(config.corda.myLegalName) } + + val useHTTPS = config.typesafe.run { hasPath("useHTTPS") && getBoolean("useHTTPS") } + if (startInProcess ?: startNodesInProcess) { val nodeAndThreadFuture = startInProcessNode(executorService, config, cordappPackages) shutdownManager.registerShutdown( @@ -622,7 +626,7 @@ class DriverDSLImpl( return nodeAndThreadFuture.flatMap { (node, thread) -> establishRpc(config, openFuture()).flatMap { rpc -> allNodesConnected(rpc).map { - NodeHandle.InProcess(rpc.nodeInfo(), rpc, config.corda, webAddress, node, thread, onNodeExit) + NodeHandle.InProcess(rpc.nodeInfo(), rpc, config.corda, webAddress, useHTTPS, node, thread, onNodeExit) } } } @@ -651,7 +655,7 @@ class DriverDSLImpl( } processDeathFuture.cancel(false) log.info("Node handle is ready. NodeInfo: ${rpc.nodeInfo()}, WebAddress: $webAddress") - NodeHandle.OutOfProcess(rpc.nodeInfo(), rpc, config.corda, webAddress, debugPort, process, onNodeExit) + NodeHandle.OutOfProcess(rpc.nodeInfo(), rpc, config.corda, webAddress, useHTTPS, debugPort, process, onNodeExit) } } }