Skip to content

Commit e3d1766

Browse files
martinwillitobiasbrunner
authored andcommitted
addrblock: Allow limiting validation depth of issuer addrblock extensions
RFC3779 requires to validate the addrblocks of issuer certificates strictly, that is, they must contain the extension and the claimed addrblock, up to the root CA. When working with third party root CAs that do not have the extension, this makes using the plugin impossible. So add a depth setting that limits the number of issuer certificates to check bottom-up towards the root CA. A depth value of 0 disables any issuer check, the default value of -1 checks all issuers in the chain, keeping the existing behavior. Closes strongswan#860
1 parent 1bb0500 commit e3d1766

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

conf/plugins/addrblock.opt

+14
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,17 @@ charon.plugins.addrblock.strict = yes
66
to no, subject certificates issued without the addrblock extension are
77
accepted without any traffic selector checks and no policy is enforced
88
by the plugin.
9+
10+
charon.plugins.addrblock.depth = -1
11+
How deep towards the root CA to validate issuer cert addrblock extensions.
12+
13+
RFC3779 requires that all addrblocks claimed by a certificate must be
14+
contained in the addrblock extension of the issuer certificate, up to
15+
the root CA. The default depth setting of -1 enforces this.
16+
17+
In practice, third party (root) CAs may not contain the extension, making
18+
the addrblock extension unusable under such CAs. By limiting the validation
19+
depth, only a certain level of issuer certificates are validated for proper
20+
addrblock extensions: A depth of 0 does not check any issuer certificate
21+
extensions, a depth of 1 only the direct issuer of the end entity
22+
certificate is checkend, and so on.

src/libcharon/plugins/addrblock/addrblock_validator.c

+18-2
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,18 @@ struct private_addrblock_validator_t {
3838
* Whether to reject subject certificates not having a addrBlock extension
3939
*/
4040
bool strict;
41+
42+
/**
43+
* How deep to validate issuer parent addrBlock validity, -1 for full
44+
*/
45+
int depth;
4146
};
4247

4348
/**
4449
* Do the addrblock check for two x509 plugins
4550
*/
4651
static bool check_addrblock(private_addrblock_validator_t *this,
47-
x509_t *subject, x509_t *issuer)
52+
x509_t *subject, x509_t *issuer, u_int pathlen)
4853
{
4954
bool subject_const, issuer_const, contained = TRUE;
5055
enumerator_t *subject_enumerator, *issuer_enumerator;
@@ -62,6 +67,15 @@ static bool check_addrblock(private_addrblock_validator_t *this,
6267
DBG1(DBG_CFG, "subject certificate lacks ipAddrBlocks extension");
6368
return !this->strict;
6469
}
70+
if (this->depth >= 0 && this->depth <= pathlen)
71+
{
72+
/* at pathlen 0: skip for depth configuration == 0,
73+
* at pathlen 1: skip for depth configurations 0..1,
74+
* ... */
75+
DBG1(DBG_CFG, " skipping issuer ipAddrBlocks validation "
76+
"at pathlen %u", pathlen);
77+
return TRUE;
78+
}
6579
if (!issuer_const)
6680
{
6781
DBG1(DBG_CFG, "issuer certificate lacks ipAddrBlocks extension");
@@ -103,7 +117,7 @@ METHOD(cert_validator_t, validate, bool,
103117
if (subject->get_type(subject) == CERT_X509 &&
104118
issuer->get_type(issuer) == CERT_X509)
105119
{
106-
if (!check_addrblock(this, (x509_t*)subject, (x509_t*)issuer))
120+
if (!check_addrblock(this, (x509_t*)subject, (x509_t*)issuer, pathlen))
107121
{
108122
lib->credmgr->call_hook(lib->credmgr, CRED_HOOK_POLICY_VIOLATION,
109123
subject);
@@ -135,6 +149,8 @@ addrblock_validator_t *addrblock_validator_create()
135149
},
136150
.strict = lib->settings->get_bool(lib->settings,
137151
"%s.plugins.addrblock.strict", TRUE, lib->ns),
152+
.depth = lib->settings->get_int(lib->settings,
153+
"%s.plugins.addrblock.depth", -1, lib->ns),
138154
);
139155

140156
return &this->public;

0 commit comments

Comments
 (0)