| 1355 | #endif |
| 1356 | |
| 1357 | void marksuperseded(cert *chain) // checks all |
| 1358 | { |
| 1359 | for(cert *c = chain; c; c = c->next) |
| 1360 | { |
| 1361 | if(c->isvalid) for(cert *r = c->next; r; r = r->next) |
| 1362 | { |
| 1363 | if(r->isvalid && c->isvalid) |
| 1364 | { |
| 1365 | if((c->type == r->type && c->name && r->name && !strcmp(c->name, r->name)) || (c->pubkey && r->pubkey && !memcmp(c->pubkey, r->pubkey, 32))) |
| 1366 | { // same name and type or same pubkey |
| 1367 | cert *x = c->signeddate < r->signeddate ? c : r; // older one has to go |
| 1368 | x->superseded = true; |
| 1369 | x->isvalid = false; |
| 1370 | } |
| 1371 | } |
| 1372 | } |
| 1373 | } |
| 1374 | for(cert *c = chain; c; c = c->next) |
| 1375 | { // check, if certs lost their parent during the cleanup above |
| 1376 | if(c->isvalid && c->parent && (!c->parent->isvalid || !c->parent->rank)) c->rank = 0; |
| 1377 | } |
| 1378 | } |
| 1379 | |
| 1380 | void rebuildcerttree() // determines the rank of all certs; ages them; removes all kinds of illegal certs |
| 1381 | { |