mirror of
https://github.com/corda/corda.git
synced 2025-06-22 17:09:00 +00:00
CORDA-3979: Support for multiple trust roots (#6772)
This commit is contained in:
@ -42,8 +42,11 @@ class PartyAndCertificate(val certPath: CertPath) {
|
||||
override fun toString(): String = party.toString()
|
||||
|
||||
/** Verify the certificate path is valid. */
|
||||
fun verify(trustAnchor: TrustAnchor): PKIXCertPathValidatorResult {
|
||||
val result = certPath.validate(trustAnchor)
|
||||
fun verify(trustAnchor: TrustAnchor): PKIXCertPathValidatorResult = verify(setOf(trustAnchor))
|
||||
|
||||
/** Verify the certificate path is valid against one of the specified trust anchors. */
|
||||
fun verify(trustAnchors: Set<TrustAnchor>): PKIXCertPathValidatorResult {
|
||||
val result = certPath.validate(trustAnchors)
|
||||
// Apply Corda-specific validity rules to the chain. This only applies to chains with any roles present, so
|
||||
// an all-null chain is in theory valid.
|
||||
var parentRole: CertRole? = CertRole.extract(result.trustAnchor.trustedCert)
|
||||
|
@ -506,8 +506,8 @@ fun ExecutorService.join() {
|
||||
}
|
||||
|
||||
// TODO: Currently the certificate revocation status is not handled here. Nowhere in the code the second parameter is used. Consider adding the support in the future.
|
||||
fun CertPath.validate(trustAnchor: TrustAnchor, checkRevocation: Boolean = false): PKIXCertPathValidatorResult {
|
||||
val parameters = PKIXParameters(setOf(trustAnchor)).apply { isRevocationEnabled = checkRevocation }
|
||||
fun CertPath.validate(trustAnchors: Set<TrustAnchor>, checkRevocation: Boolean = false): PKIXCertPathValidatorResult {
|
||||
val parameters = PKIXParameters(trustAnchors).apply { isRevocationEnabled = checkRevocation }
|
||||
try {
|
||||
return CertPathValidator.getInstance("PKIX").validate(this, parameters) as PKIXCertPathValidatorResult
|
||||
} catch (e: CertPathValidatorException) {
|
||||
@ -517,8 +517,8 @@ Reason: ${e.reason}
|
||||
Offending cert index: ${e.index}
|
||||
Cert path: $this
|
||||
|
||||
Trust anchor:
|
||||
$trustAnchor""", e, this, e.index)
|
||||
Trust anchors:
|
||||
$trustAnchors""", e, this, e.index)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -40,5 +40,5 @@ interface NetworkParametersStorage : NetworkParametersService {
|
||||
/**
|
||||
* Set information that given parameters are current parameters for the network.
|
||||
*/
|
||||
fun setCurrentParameters(currentSignedParameters: SignedDataWithCert<NetworkParameters>, trustRoot: X509Certificate)
|
||||
fun setCurrentParameters(currentSignedParameters: SignedDataWithCert<NetworkParameters>, trustRoots: Set<X509Certificate>)
|
||||
}
|
||||
|
Reference in New Issue
Block a user