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

问题描述 投票:0回答:1

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

enter image description here

x509certificate corda
1个回答
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
投票

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

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)
    }
© www.soinside.com 2019 - 2024. All rights reserved.