mirror of
https://github.com/corda/corda.git
synced 2025-05-03 17:23:03 +00:00
Merge pull request #7323 from corda/shams-ent-8898-cherrypick
ENT-8898: Revert change made to externalCrlSource checking
This commit is contained in:
commit
d140cb5974
@ -11,7 +11,6 @@ import java.security.cert.PKIXRevocationChecker
|
|||||||
* Data structure for controlling the way how Certificate Revocation Lists are handled.
|
* Data structure for controlling the way how Certificate Revocation Lists are handled.
|
||||||
*/
|
*/
|
||||||
@CustomConfigParser(parser = RevocationConfigParser::class)
|
@CustomConfigParser(parser = RevocationConfigParser::class)
|
||||||
// TODO This and RevocationConfigImpl should really be a single sealed data type
|
|
||||||
interface RevocationConfig {
|
interface RevocationConfig {
|
||||||
|
|
||||||
enum class Mode {
|
enum class Mode {
|
||||||
@ -47,15 +46,13 @@ interface RevocationConfig {
|
|||||||
*/
|
*/
|
||||||
val externalCrlSource: CrlSource?
|
val externalCrlSource: CrlSource?
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a copy of [RevocationConfig] enriched by a [CrlSource].
|
|
||||||
*/
|
|
||||||
fun enrichExternalCrlSource(sourceFunc: (() -> CrlSource)?): RevocationConfig
|
|
||||||
|
|
||||||
fun createPKIXRevocationChecker(): PKIXRevocationChecker {
|
fun createPKIXRevocationChecker(): PKIXRevocationChecker {
|
||||||
return when (mode) {
|
return when (mode) {
|
||||||
Mode.OFF -> AllowAllRevocationChecker
|
Mode.OFF -> AllowAllRevocationChecker
|
||||||
Mode.EXTERNAL_SOURCE -> CordaRevocationChecker(externalCrlSource!!, softFail = true)
|
Mode.EXTERNAL_SOURCE -> {
|
||||||
|
val externalCrlSource = requireNotNull(externalCrlSource) { "externalCrlSource must be specfied for EXTERNAL_SOURCE" }
|
||||||
|
CordaRevocationChecker(externalCrlSource, softFail = true)
|
||||||
|
}
|
||||||
Mode.SOFT_FAIL -> CordaRevocationChecker(CertDistPointCrlSource(), softFail = true)
|
Mode.SOFT_FAIL -> CordaRevocationChecker(CertDistPointCrlSource(), softFail = true)
|
||||||
Mode.HARD_FAIL -> CordaRevocationChecker(CertDistPointCrlSource(), softFail = false)
|
Mode.HARD_FAIL -> CordaRevocationChecker(CertDistPointCrlSource(), softFail = false)
|
||||||
}
|
}
|
||||||
@ -67,24 +64,7 @@ interface RevocationConfig {
|
|||||||
*/
|
*/
|
||||||
fun Boolean.toRevocationConfig() = if(this) RevocationConfigImpl(RevocationConfig.Mode.SOFT_FAIL) else RevocationConfigImpl(RevocationConfig.Mode.HARD_FAIL)
|
fun Boolean.toRevocationConfig() = if(this) RevocationConfigImpl(RevocationConfig.Mode.SOFT_FAIL) else RevocationConfigImpl(RevocationConfig.Mode.HARD_FAIL)
|
||||||
|
|
||||||
data class RevocationConfigImpl(override val mode: RevocationConfig.Mode, override val externalCrlSource: CrlSource? = null) : RevocationConfig {
|
data class RevocationConfigImpl(override val mode: RevocationConfig.Mode, override val externalCrlSource: CrlSource? = null) : RevocationConfig
|
||||||
init {
|
|
||||||
if (mode == RevocationConfig.Mode.EXTERNAL_SOURCE) {
|
|
||||||
requireNotNull(externalCrlSource) { "externalCrlSource must not be null" }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO This doesn't really need to be a member method. All it does is change externalCrlSource if applicable, which is the same as
|
|
||||||
// just creating a new RevocationConfigImpl with that CrlSource.
|
|
||||||
override fun enrichExternalCrlSource(sourceFunc: (() -> CrlSource)?): RevocationConfig {
|
|
||||||
return if (mode != RevocationConfig.Mode.EXTERNAL_SOURCE) {
|
|
||||||
this
|
|
||||||
} else {
|
|
||||||
val func = requireNotNull(sourceFunc) { "There should be a way to obtain CrlSource" }
|
|
||||||
copy(externalCrlSource = func())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class RevocationConfigParser : ConfigParser<RevocationConfig> {
|
class RevocationConfigParser : ConfigParser<RevocationConfig> {
|
||||||
override fun parse(config: Config): RevocationConfig {
|
override fun parse(config: Config): RevocationConfig {
|
||||||
|
@ -201,7 +201,7 @@ class CertificateRevocationListNodeTests {
|
|||||||
verifyAMQPConnection(
|
verifyAMQPConnection(
|
||||||
crlCheckSoftFail = true,
|
crlCheckSoftFail = true,
|
||||||
nodeCrlDistPoint = "http://${newUnreachableIpAddress()}/crl/unreachable.crl",
|
nodeCrlDistPoint = "http://${newUnreachableIpAddress()}/crl/unreachable.crl",
|
||||||
sslHandshakeTimeout = crlConnectTimeout * 2,
|
sslHandshakeTimeout = crlConnectTimeout * 3,
|
||||||
expectedConnectStatus = true
|
expectedConnectStatus = true
|
||||||
)
|
)
|
||||||
val timeoutExceptions = (amqpServer.softFailExceptions + amqpClient.softFailExceptions)
|
val timeoutExceptions = (amqpServer.softFailExceptions + amqpClient.softFailExceptions)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user