如何在Corda中手动生成网络参数

时间:2019-04-18 10:05:32

标签: x509certificate corda

我已经手动创建并分发了Corda节点所需的证书。现在,要启动节点,除其他事项外,它们需要具有网络参数。问题是,如果我使用Corda网络引导程序工具生成网络参数,则该文件将由另一个发行者签名(“ C = UK,L =伦敦,OU = corda,O = R3,CN = Corda节点根CA ”)与我的证书的签发人不同。我的问题是如何手动创建网络参数,以便可以指定正确的颁发者以避免节点启动期间发生冲突?

enter image description here

2 个答案:

答案 0 :(得分:1)

您可以使用网络引导程序使用的开发证书对证书进行签名:https://github.com/corda/corda/tree/master/node-api/src/main/resources/certificates

如果这对您不起作用,则可以尝试使用以下实验工具:https://github.com/corda/corda/blob/master/experimental/netparams/src/main/kotlin/net.corda.netparams/NetParams.kt。我不能保证它可以在Corda 3.3中使用。

答案 1 :(得分:0)

所以我想出了一种创建网络参数的方法:

private fun getSignedNetworkParameters(): NetworkParameters {

        //load the notary from a Keystore. This avoids having to start a flow from a node in order to retrieve NotaryInfo
        val notary = loadKeyStore("\\path-to-keystore\\keystore.jks", "keystore-password")

        val certificateAndKeyPair : CertificateAndKeyPair = notary.getCertificateAndKeyPair("entry-alias", "entry-password")
        val notaryParty = Party(certificateAndKeyPair.certificate)
        val notaryInfo = listOf(NotaryInfo(notaryParty, false))

        //map contract ID to the SHA-256 hash of its CorDapp contracts&states JAR file
        val whitelistedContractImplementations = mapOf(
                TestContract.TEST_CONTRACT_ID to listOf(getCheckSum(contractFile))
        )

        return NetworkParameters(minimumPlatformVersion = 3, notaries = notaryInfo,
                maxMessageSize = n, maxTransactionSize = n, modifiedTime = Instant.now(),
                epoch = 1, whitelistedContractImplementations = whitelistedContractImplementations)
    }