mirror of
https://github.com/corda/corda.git
synced 2025-02-20 17:33:15 +00:00
[CORDA-1880]: Exception if timeout during initial registration (fixed). (#3748)
This commit is contained in:
parent
f160d0800b
commit
6255459ce7
@ -23,7 +23,7 @@ import net.corda.node.services.transactions.bftSMaRtSerialFilter
|
||||
import net.corda.node.utilities.createKeyPairAndSelfSignedTLSCertificate
|
||||
import net.corda.node.utilities.registration.HTTPNetworkRegistrationService
|
||||
import net.corda.node.utilities.registration.NodeRegistrationHelper
|
||||
import net.corda.node.utilities.registration.UnableToRegisterNodeWithDoormanException
|
||||
import net.corda.node.utilities.registration.NodeRegistrationException
|
||||
import net.corda.node.utilities.saveToKeyStore
|
||||
import net.corda.node.utilities.saveToTrustStore
|
||||
import net.corda.nodeapi.internal.addShutdownHook
|
||||
@ -140,13 +140,13 @@ open class NodeStartup(val args: Array<String>) {
|
||||
if (cmdlineOptions.nodeRegistrationOption != null) {
|
||||
// Null checks for [compatibilityZoneURL], [rootTruststorePath] and [rootTruststorePassword] has been done in [CmdLineOptions.loadConfig]
|
||||
registerWithNetwork(conf, versionInfo, cmdlineOptions.nodeRegistrationOption)
|
||||
// At this point the node registration was succesfull. We can delete the marker file.
|
||||
// At this point the node registration was successful. We can delete the marker file.
|
||||
deleteNodeRegistrationMarker(cmdlineOptions.baseDirectory)
|
||||
return true
|
||||
}
|
||||
logStartupInfo(versionInfo, cmdlineOptions, conf)
|
||||
} catch (e: UnableToRegisterNodeWithDoormanException) {
|
||||
logger.warn("Node registration service is unavailable. Perhaps try to perform the initial registration again after a while.")
|
||||
} catch (e: NodeRegistrationException) {
|
||||
logger.warn("Node registration service is unavailable. Perhaps try to perform the initial registration again after a while.", e)
|
||||
return false
|
||||
} catch (e: Exception) {
|
||||
logger.error("Exception during node registration", e)
|
||||
|
@ -18,6 +18,7 @@ import org.bouncycastle.openssl.jcajce.JcaPEMWriter
|
||||
import org.bouncycastle.util.io.pem.PemObject
|
||||
import java.io.IOException
|
||||
import java.io.StringWriter
|
||||
import java.net.ConnectException
|
||||
import java.nio.file.Path
|
||||
import java.security.KeyPair
|
||||
import java.security.KeyStore
|
||||
@ -90,7 +91,14 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
||||
|
||||
val keyPair = nodeKeyStore.loadOrCreateKeyPair(SELF_SIGNED_PRIVATE_KEY)
|
||||
|
||||
val requestId = submitOrResumeCertificateSigningRequest(keyPair)
|
||||
val requestId = try {
|
||||
submitOrResumeCertificateSigningRequest(keyPair)
|
||||
} catch (e: Exception) {
|
||||
if (e is ConnectException || e is ServiceUnavailableException || e is IOException) {
|
||||
throw NodeRegistrationException(e)
|
||||
}
|
||||
throw e
|
||||
}
|
||||
|
||||
val certificates = try {
|
||||
pollServerForCertificates(requestId)
|
||||
@ -103,7 +111,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
||||
}
|
||||
validateCertificates(keyPair.public, certificates)
|
||||
storePrivateKeyWithCertificates(nodeKeyStore, keyPair, certificates, keyAlias)
|
||||
onSuccess(keyPair, certificates, tlsCrlIssuerCert?.let { it.subjectX500Principal.toX500Name() })
|
||||
onSuccess(keyPair, certificates, tlsCrlIssuerCert?.subjectX500Principal?.toX500Name())
|
||||
// All done, clean up temp files.
|
||||
requestIdStore.deleteIfExists()
|
||||
}
|
||||
@ -183,7 +191,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
||||
if (idlePeriodDuration != null) {
|
||||
Thread.sleep(idlePeriodDuration.toMillis())
|
||||
} else {
|
||||
throw UnableToRegisterNodeWithDoormanException()
|
||||
throw NodeRegistrationException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -232,7 +240,7 @@ open class NetworkRegistrationHelper(private val config: SSLConfiguration,
|
||||
protected open fun isTlsCrlIssuerCertRequired(): Boolean = false
|
||||
}
|
||||
|
||||
class UnableToRegisterNodeWithDoormanException : IOException()
|
||||
class NodeRegistrationException(cause: Throwable?) : IOException("Unable to contact node registration service", cause)
|
||||
|
||||
class NodeRegistrationHelper(private val config: NodeConfiguration, certService: NetworkRegistrationService, regConfig: NodeRegistrationOption, computeNextIdleDoormanConnectionPollInterval: (Duration?) -> Duration? = FixedPeriodLimitedRetrialStrategy(10, Duration.ofMinutes(1))) :
|
||||
NetworkRegistrationHelper(config,
|
||||
|
Loading…
x
Reference in New Issue
Block a user