00001
00009 #include "PKIFPathBasicChecks2.h"
00010
00011 #include "ToolkitUtils.h"
00012 #include "BasicChecksUtils.h"
00013 #include "PKIFErrors.h"
00014
00015 #include "PKIFCertificatePath.h"
00016 #include "PKIFTrustRoot.h"
00017 #include "PKIFCertStatus.h"
00018 #include "PKIFCertificateNodeEntry.h"
00019 #include "PKIFTime.h"
00020 #include "PolicyInformation.h"
00021 #include "OID.h"
00022 #include "PKIFPathSettings.h"
00023 #include "PathResults.h"
00024 #include "GeneralSubtree.h"
00025 #include "Certificate.h"
00026 #include "SubjectPublicKeyInfo.h"
00027 #include "Validity.h"
00028 #include "PolicyInformationSet.h"
00029 #include "Name.h"
00030 #include "PolicyConstraints.h"
00031 #include "BasicConstraints.h"
00032 #include "KeyUsage.h"
00033 #include "NameConstraints.h"
00034 #include "InhibitAnyPolicy.h"
00035 #include "PKIFFuncStorage.h"
00036 #include "SubjectAltName.h"
00037 #include "X509Extension.h"
00038 #include "PolicyMappings.h"
00039
00040 #ifdef _DEBUG_PATH
00041 #include <iostream>
00042 #endif
00043 using namespace std;
00044 #include <cstring>
00045
00053 CPKIFPathBasicChecks2::CPKIFPathBasicChecks2(void)
00054 {
00055 LOG_STRING_DEBUG("CPKIFPathBasicChecks2::CPKIFPathBasicChecks2(void)", TOOLKIT_PATH_BASIC_CHECKS, 0, this);
00056 }
00064 CPKIFPathBasicChecks2::~CPKIFPathBasicChecks2(void)
00065 {
00066 LOG_STRING_DEBUG("CPKIFPathBasicChecks2::~CPKIFPathBasicChecks2(void)", TOOLKIT_PATH_BASIC_CHECKS, 0, this);
00067 }
00124 bool CPKIFPathBasicChecks2::DoChecks(
00126 const CPKIFCertificatePath& path,
00128 CPKIFPathValidationResults& results,
00131 CPKIFFuncStoragePtr& funcs)
00132 {
00133 #undef ERROR_OVERRIDE
00134 #define ERROR_OVERRIDE(errCode) \
00135 { \
00136 bool override = false;\
00137 bool (*fp) (int, CPKIFCertificatePtr&,const CPKIFCertificatePath&) = settings->GetOverrideCallback(); \
00138 if(NULL != fp) \
00139 { \
00140 if(fp(errCode, curCert, path))\
00141 override = true; \
00142 } \
00143 if(!override) \
00144 {\
00145 CPKIFCertStatusPtr status(new CPKIFCertStatus); \
00146 status->SetDiagnosticCode(errCode); \
00147 (*pos)->SetStatus(status); \
00148 results.SetCertificate(*pos); \
00149 isPathGood = false; \
00150 break;\
00151 }\
00152 }\
00153
00154
00155 LOG_STRING_DEBUG("CPKIFPathBasicChecks2::DoChecks", TOOLKIT_PATH_BASIC_CHECKS, 0, NULL);
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168 CPKIFCertificateNodeList certNodeList;
00169 path.GetPath(certNodeList);
00170
00171
00172 if(0 == certNodeList.size())
00173 {
00174 RAISE_PATH_EXCEPTION("Empty certificate path parameter.", thisComponent, COMMON_INVALID_INPUT, NULL)
00175 }
00176
00177 IPKIFTrustAnchorPtr trustRoot;
00178 path.GetTrustRoot(trustRoot);
00179 if(trustRoot == (IPKIFTrustAnchor*)NULL)
00180 {
00181 RAISE_PATH_EXCEPTION("Path does not specify a trust root.", thisComponent, PATH_TRUST_ROOT_NOT_SET, NULL)
00182 }
00183 else
00184 results.SetTrustAnchor(trustRoot);
00185
00186 IPKIFNameAndKey* prevCert = dynamic_cast<IPKIFNameAndKey*>(&(*(trustRoot)));
00187
00188
00189 CPKIFNamePtr lastCertName;
00190 lastCertName = trustRoot->GetSubjectName();
00191 if(lastCertName == (CPKIFName*)NULL)
00192 {
00193 RAISE_PATH_EXCEPTION("Trust root is not a certificate.", thisComponent, PATH_TRUST_ROOT_NO_CERT, NULL)
00194 }
00195
00196
00197 {
00198 CPKIFCertificateNodeList::iterator pos;
00199 CPKIFCertificateNodeList::iterator end = certNodeList.end();
00200 for(pos = certNodeList.begin(); pos != end; ++pos)
00201 {
00202 CPKIFCertStatusPtr newStatus(new CPKIFCertStatus);
00203 (*pos)->SetStatus(newStatus);
00204 }
00205 }
00206
00207
00208
00209
00210
00211 CPKIFPathSettingsPtr settings;
00212 path.GetPathSettings(settings);
00213
00214
00215
00216
00217 CPKIFTimePtr curTime = settings->GetValidationTime();
00218 if(curTime == (CPKIFTime*)NULL)
00219 curTime = CPKIFTime::CurrentTime();
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232 vector<CPKIFPolicyInformationListPtr>* authSet = new vector<CPKIFPolicyInformationListPtr>;
00233
00234
00235 results.SetAuthorityConstrainedSet(authSet);
00236
00237 CPKIFPolicyInformationListPtr zeroRow(new CPKIFPolicyInformationList);
00238 CPKIFOIDPtr anyPolicy(new CPKIFOID(CPKIFStringPtr(new std::string("2.5.29.32.0"))));
00239 zeroRow->push_back(CPKIFPolicyInformationPtr(new CPKIFPolicyInformation(anyPolicy)));
00240 zeroRow->push_back(CPKIFPolicyInformationPtr(new CPKIFPolicyInformation(anyPolicy)));
00241 authSet->push_back(zeroRow);
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251 CPKIFGeneralSubtreeListPtr permSubtrees;
00252 CPKIFGeneralSubtreeListPtr exclSubtrees;
00253 settings->GetInitialPermSubtrees(permSubtrees);
00254 settings->GetInitialExclSubtrees(exclSubtrees);
00255
00256 if(permSubtrees == (CPKIFGeneralSubtreeList*)NULL)
00257 {
00258 CPKIFGeneralSubtreeListPtr tmp(new CPKIFGeneralSubtreeList);
00259 permSubtrees = tmp;
00260 }
00261 if(exclSubtrees == (CPKIFGeneralSubtreeList*)NULL)
00262 {
00263 CPKIFGeneralSubtreeListPtr tmp(new CPKIFGeneralSubtreeList);
00264 exclSubtrees = tmp;
00265 }
00266
00267
00268
00269
00270 std::bitset<3> indicators;
00271 indicators.reset();
00272 if(settings != (CPKIFPathSettings*)NULL)
00273 {
00274 indicators.set(CPKIFPathSettings::EXPLICIT_POLICY, settings->GetInitialExplicitPolicyIndicator());
00275 indicators.set(CPKIFPathSettings::POLICY_MAPPING, settings->GetInitialPolicyMappingInhibitIndicator());
00276 indicators.set(CPKIFPathSettings::ANY_POLICY, settings->GetInitialInhibitAnyPolicyIndicator());
00277 }
00278
00279
00280 int pathDepth = 1;
00281
00282
00283 bool bPendingExplicitPolicy = false;
00284 int nPendingExplicitPolicy = -1;
00285 bool bPendingPolicyMapping = false;
00286 int nPendingPolicyMapping = -1;
00287 bool bPendingAnyPolicy = false;
00288 int nPendingAnyPolicy = -1;
00289 bool bPathLength = false;
00290 int nPathLength = -1;
00291
00292 bool permSubtreesSet = false;
00293
00294 #ifdef _DEBUG_PATH
00295 {
00296 cout << "Dumping path..." << endl;
00297 cout << "Trust root: " << lastCertName->ToString() << endl;
00298
00299 CPKIFCertificateNodeList::iterator pos;
00300 CPKIFCertificateNodeList::iterator end = certNodeList.end();
00301 for(pos = certNodeList.begin(); pos != end; ++pos)
00302 cout << "Cert: " << (*pos)->GetCert()->Subject()->ToString() << endl;
00303 }
00304 #endif
00305
00306
00307 bool isPathGood = true;
00308 CPKIFCertificatePtr curCert;
00309 CPKIFCertificateNodeList::iterator pos;
00310 CPKIFCertificateNodeList::iterator end = certNodeList.end();
00311 for(pos = certNodeList.begin(); pos != end; ++pos)
00312 {
00313
00314 curCert = (*pos)->GetCert();
00315 (*pos)->ClearProcessedExtensions();
00316
00317
00318 bool isSelfIssued = curCert->IsSelfIssued();
00319
00320
00321
00322 if(isSelfIssued)
00323 {
00324
00325
00326
00330
00331
00332 if(curCert->IsSelfSigned())
00333 continue;
00334 }
00335 else
00336 {
00337
00338
00339 if(bPathLength)
00340 --nPathLength;
00341 }
00342
00343
00344
00345
00346
00347 CPKIFAlgorithmIdentifierPtr prevCertSigAlg = prevCert->GetSubjectPublicKeyInfo()->alg();
00348 CPKIFAlgorithmIdentifierPtr curCertSigAlg = curCert->SignatureAlgorithm();
00349 AlgClass prevAC = GetAlgClass(prevCertSigAlg);
00350 AlgClass curAC = GetAlgClass(curCertSigAlg);
00351 if(prevAC != curAC)
00352 {
00353 ERROR_OVERRIDE(PATH_SIGNATURE_VERIFICATION_FAILED);
00354 }
00355
00356 #ifdef _DEBUG_PATH
00357 const char* curCertString = curCert->Subject()->ToString();
00358 cout << "Processing certificate with subject: " << curCertString << endl;
00359 #endif
00360
00361
00362 if(!(*lastCertName == *curCert->Issuer()))
00363 {
00364 #ifdef _DEBUG_PATH
00365 cout << lastCertName->ToString() << " != " << curCert->Issuer()->ToString() << endl;
00366 #endif
00367
00368 ERROR_OVERRIDE(PATH_NAME_CHAINING_VIOLATION);
00369 }
00370
00371 lastCertName = curCert->Subject();
00372 prevCert = dynamic_cast<IPKIFNameAndKey*>(&(*(curCert)));
00373
00374
00375 CPKIFValidityPtr val = curCert->Validity();
00376 CPKIFTimePtr startTime = val->notBefore();
00377 CPKIFTimePtr endTime = val->notAfter();
00378 if(*curTime < *startTime)
00379 {
00380 ERROR_OVERRIDE(PATH_VALIDITY_PERIOD_VIOLATION_NOT_YET_VALID);
00381 }
00382
00383 if(*curTime > *endTime)
00384 {
00385 ERROR_OVERRIDE(PATH_VALIDITY_PERIOD_VIOLATION_EXPIRED);
00386 }
00387
00388
00389 CPKIFPolicyInformationSetPtr certPols = curCert->GetExtension<CPKIFPolicyInformationSet>();
00390 if(certPols != (CPKIFPolicyInformationSet*)NULL)
00391 {
00392
00393 AddPoliciesToAuthSet(certPols, indicators, *authSet, isSelfIssued, pos+1 != end);
00394 CPKIFX509ExtensionPtr cp2 = certPols;
00395 (*pos)->MarkExtensionAsProcessed(cp2);
00396 }
00397 else
00398 {
00399
00400
00401
00402
00403
00404 authSet->clear();
00405 }
00406
00407
00408
00409
00410
00411 if(!(pos+1 != end && isSelfIssued))
00412 {
00413 try
00414 {
00415
00416 if(!CheckNameConstraints(curCert, permSubtrees, exclSubtrees, permSubtreesSet))
00417 {
00418 ERROR_OVERRIDE(PATH_NAME_CONSTRAINTS_VIOLATION);
00419 }
00420 }
00421 catch(CPKIFException&e)
00422 {
00423 if(e.GetErrorCode() == ASN1_DECODE_ERROR && strcmp(e.GetDescription(), "encountered malformed uriName") == 0)
00424 {
00425 ERROR_OVERRIDE(PATH_NAME_CONSTRAINTS_VIOLATION);
00426 }
00427 else
00428 {
00429 throw e;
00430 }
00431 }
00432 }
00433
00434
00435 CPKIFPolicyConstraintsPtr policyConstraints = curCert->GetExtension<CPKIFPolicyConstraints>();
00436
00437 if(pos+1 != end)
00438 {
00439 if(bPathLength && nPathLength < 0)
00440 {
00441 ERROR_OVERRIDE(PATH_LENGTH_VIOLATION);
00442 }
00443
00444
00445 CPKIFBasicConstraintsPtr basicConstraints = curCert->GetExtension<CPKIFBasicConstraints>();
00446 bool isCA = false;
00447 if(basicConstraints != (CPKIFBasicConstraints*)NULL)
00448 {
00449 CPKIFX509ExtensionPtr basicConstraints2 = basicConstraints;
00450 (*pos)->MarkExtensionAsProcessed(basicConstraints2);
00451
00452 if(basicConstraints->isCA())
00453 isCA = true;
00454
00455 if(basicConstraints->pathLengthPresent())
00456 {
00457 if(bPathLength)
00458 nPathLength = min(nPathLength, basicConstraints->pathLength());
00459 else
00460 {
00461 bPathLength = true;
00462 nPathLength = basicConstraints->pathLength();
00463 }
00464 }
00465 }
00466
00467 if(!isCA)
00468 {
00469
00470 ERROR_OVERRIDE(PATH_BASIC_CONSTRAINTS_VIOLATION);
00471 }
00472
00473 CPKIFKeyUsagePtr keyUsage = curCert->GetExtension<CPKIFKeyUsage>();
00474 if(keyUsage != (CPKIFKeyUsage*)NULL)
00475 {
00476 CPKIFX509ExtensionPtr keyUsage2 = keyUsage;
00477 (*pos)->MarkExtensionAsProcessed(keyUsage2);
00478
00479
00480 if(!keyUsage->KeyCertSign())
00481 {
00482 ERROR_OVERRIDE(PATH_KEY_USAGE_VIOLATION);
00483 }
00484 }
00485
00486
00487
00488
00489
00490
00491
00492
00493 CPKIFNameConstraintsPtr nameConstraints = curCert->GetExtension<CPKIFNameConstraints>();
00494 if(nameConstraints != (CPKIFNameConstraints*)NULL)
00495 {
00496 try
00497 {
00498
00499 CPKIFGeneralSubtreeListPtr perm = nameConstraints->GetPermitted();
00500 if(perm != (CPKIFGeneralSubtreeList*)NULL)
00501 {
00502 CPKIFGeneralSubtreeListPtr tmpSubtrees(new CPKIFGeneralSubtreeList);
00503 IntersectSubtrees(perm, permSubtrees, tmpSubtrees);
00504 permSubtrees = tmpSubtrees;
00505 if(!permSubtreesSet)
00506 permSubtreesSet = permSubtrees->empty();
00507 }
00508
00509 CPKIFGeneralSubtreeListPtr excl = nameConstraints->GetExcluded();
00510 if(excl != (CPKIFGeneralSubtreeList*)NULL)
00511 {
00512 CPKIFGeneralSubtreeList::iterator exclPos;
00513 CPKIFGeneralSubtreeList::iterator exclEnd = excl->end();
00514 for(exclPos = excl->begin(); exclEnd != exclPos; ++exclPos)
00515 exclSubtrees->push_back(*exclPos);
00516 }
00517
00518 CPKIFX509ExtensionPtr nameConstraints2 = nameConstraints;
00519 (*pos)->MarkExtensionAsProcessed(nameConstraints2);
00520 }
00521 catch(CPKIFException& e)
00522 {
00523
00524
00525 if(nameConstraints->isCritical())
00526 throw e;
00527
00528
00529 }
00530 }
00531
00532
00533 CPKIFPolicyMappingsPtr policyMappings = curCert->GetExtension<CPKIFPolicyMappings>();
00534 if(policyMappings != (CPKIFPolicyMappings*)NULL)
00535 {
00536 ProcessPolicyMapping(policyMappings, indicators, *authSet);
00537 CPKIFX509ExtensionPtr policyMappings2 = policyMappings;
00538 (*pos)->MarkExtensionAsProcessed(policyMappings2);
00539 }
00540
00541
00542
00543
00544 if(bPendingPolicyMapping && !isSelfIssued && !indicators[CPKIFPathSettings::POLICY_MAPPING])
00545 {
00546 --nPendingPolicyMapping;
00547 if(0 == nPendingPolicyMapping)
00548 {
00549 indicators.set(CPKIFPathSettings::POLICY_MAPPING);
00550 }
00551 }
00552
00553 if(policyConstraints != (CPKIFPolicyConstraints*)NULL)
00554 {
00555 if(policyConstraints->InhibitPolicyMappingPresent())
00556 {
00557 if(bPendingPolicyMapping)
00558 nPendingPolicyMapping = min(nPendingPolicyMapping, policyConstraints->InhibitPolicyMapping());
00559 else
00560 {
00561 bPendingPolicyMapping = true;
00562 nPendingPolicyMapping = policyConstraints->InhibitPolicyMapping();
00563 }
00564 }
00565
00566
00567 if(0 == nPendingPolicyMapping)
00568 indicators.set(CPKIFPathSettings::POLICY_MAPPING);
00569
00570 CPKIFX509ExtensionPtr policyConstraints2 = policyConstraints;
00571 (*pos)->MarkExtensionAsProcessed(policyConstraints2);
00572 }
00573
00574
00575
00576
00577 vector<CPKIFPolicyInformationListPtr>::iterator authSetPos;
00578 vector<CPKIFPolicyInformationListPtr>::iterator authSetEnd = authSet->end();
00579 const size_t pathDepthPlusOne = pathDepth + 1;
00580 for(authSetPos = authSet->begin(); authSetPos != authSetEnd; ++authSetPos)
00581 {
00582 const size_t curSize = (*authSetPos)->size();
00583 if(curSize == pathDepthPlusOne)
00584 {
00585 CPKIFPolicyInformationPtr lastPol = (*authSetPos)->back();
00586 (*authSetPos)->push_back(lastPol);
00587 }
00588 }
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599 if(bPendingAnyPolicy && !isSelfIssued && !indicators[CPKIFPathSettings::ANY_POLICY])
00600 {
00601 --nPendingAnyPolicy;
00602 if(0 == nPendingAnyPolicy)
00603 {
00604 indicators.set(CPKIFPathSettings::ANY_POLICY);
00605 }
00606 }
00607
00608 CPKIFInhibitAnyPolicyPtr inhibitAnyPolicy = curCert->GetExtension<CPKIFInhibitAnyPolicy>();
00609 if(inhibitAnyPolicy != (CPKIFInhibitAnyPolicy*)NULL)
00610 {
00611 CPKIFX509ExtensionPtr inhibitAnyPolicy2 = inhibitAnyPolicy;
00612 (*pos)->MarkExtensionAsProcessed(inhibitAnyPolicy2);
00613
00614 if(!indicators[CPKIFPathSettings::ANY_POLICY])
00615 {
00616 if(bPendingAnyPolicy)
00617 nPendingAnyPolicy = min(nPendingAnyPolicy, inhibitAnyPolicy->SkipCerts());
00618 else
00619 {
00620 bPendingAnyPolicy = true;
00621 nPendingAnyPolicy = inhibitAnyPolicy->SkipCerts();
00622 }
00623
00624
00625 if(0 == nPendingAnyPolicy)
00626 indicators.set(CPKIFPathSettings::ANY_POLICY);
00627 }
00628 }
00629
00630 }
00631 else
00632 {
00633
00634
00635
00636
00637
00638 CPKIFBasicConstraintsPtr basicConstraints = curCert->GetExtension<CPKIFBasicConstraints>();
00639 bool isCA = false;
00640 if(basicConstraints != (CPKIFBasicConstraints*)NULL)
00641 {
00642 CPKIFX509ExtensionPtr basicConstraints2 = basicConstraints;
00643 (*pos)->MarkExtensionAsProcessed(basicConstraints2);
00644 }
00645
00646 CPKIFPolicyMappingsPtr policyMappings = curCert->GetExtension<CPKIFPolicyMappings>();
00647 if(policyMappings != (CPKIFPolicyMappings*)NULL)
00648 {
00649
00650 ProcessPolicyMapping(policyMappings, indicators, *authSet);
00651
00652 CPKIFX509ExtensionPtr policyMappings2 = policyMappings;
00653 (*pos)->MarkExtensionAsProcessed(policyMappings2);
00654 }
00655
00656 CPKIFNameConstraintsPtr nameConstraints = curCert->GetExtension<CPKIFNameConstraints>();
00657 if(nameConstraints != (CPKIFNameConstraints*)NULL)
00658 {
00659 CPKIFX509ExtensionPtr nameConstraints2 = nameConstraints;
00660 (*pos)->MarkExtensionAsProcessed(nameConstraints2);
00661 }
00662
00663 if(policyConstraints != (CPKIFPolicyConstraints*)NULL)
00664 {
00665 CPKIFX509ExtensionPtr policyConstraints2 = policyConstraints;
00666 (*pos)->MarkExtensionAsProcessed(policyConstraints2);
00667 }
00668
00669 CPKIFInhibitAnyPolicyPtr inhibitAnyPolicy = curCert->GetExtension<CPKIFInhibitAnyPolicy>();
00670 if(inhibitAnyPolicy != (CPKIFInhibitAnyPolicy*)NULL)
00671 {
00672 CPKIFX509ExtensionPtr inhibitAnyPolicy2 = inhibitAnyPolicy;
00673 (*pos)->MarkExtensionAsProcessed(inhibitAnyPolicy2);
00674 }
00675 }
00676
00677
00678
00679
00680
00681
00682
00683 if(bPendingExplicitPolicy && !(isSelfIssued && pos+1 != end) && !indicators[CPKIFPathSettings::EXPLICIT_POLICY])
00684 {
00685 --nPendingExplicitPolicy;
00686 if(0 == nPendingExplicitPolicy)
00687 {
00688 indicators.set(CPKIFPathSettings::EXPLICIT_POLICY);
00689 }
00690 }
00691
00692 if(policyConstraints != (CPKIFPolicyConstraints*)NULL)
00693 {
00694
00695 if(policyConstraints->RequireExplicitPolicyPresent())
00696 {
00697 if(bPendingExplicitPolicy)
00698 nPendingExplicitPolicy = min(nPendingExplicitPolicy, policyConstraints->RequireExplicitPolicy());
00699 else
00700 {
00701 bPendingExplicitPolicy = true;
00702 nPendingExplicitPolicy = policyConstraints->RequireExplicitPolicy();
00703 }
00704
00705 if(0 == nPendingExplicitPolicy)
00706 {
00707 indicators.set(CPKIFPathSettings::EXPLICIT_POLICY);
00708 }
00709 }
00710 }
00711
00712 if(indicators[CPKIFPathSettings::EXPLICIT_POLICY] && authSet->empty())
00713 {
00714
00715
00716 ERROR_OVERRIDE(PATH_NULL_AUTH_POLICY_SET);
00717 }
00718
00719 CPKIFFuncStorageSingleton* fss = CPKIFFuncStorageSingleton::GetInstance();
00720 if(fss != (CPKIFFuncStorageSingleton*)NULL && !fss->empty())
00721 {
00722 try
00723 {
00724 if(pos+1 == end)
00725 (*fss)(*pos, results, EE);
00726 else
00727 (*fss)(*pos, results, INTERMEDIATE);
00728 }
00729 catch(CPKIFException&)
00730 {
00731
00732
00733 ERROR_OVERRIDE(PATH_APP_DEFINED_CHECK_FAILED);
00734 }
00735 }
00736
00737
00738 if(funcs != (CPKIFFuncStorage*)NULL && !funcs->empty())
00739 {
00740 try
00741 {
00742 if(pos+1 == end)
00743 (*funcs)(*pos, results, EE);
00744 else
00745 (*funcs)(*pos, results, INTERMEDIATE);
00746 }
00747 catch(CPKIFException&)
00748 {
00749
00750
00751 ERROR_OVERRIDE(PATH_APP_DEFINED_CHECK_FAILED);
00752 }
00753 }
00754
00755
00756 CPKIFSubjectAltNamePtr san = curCert->GetExtension<CPKIFSubjectAltName>();
00757 if(san != (CPKIFSubjectAltName*)NULL)
00758 {
00759 CPKIFX509ExtensionPtr san2 = san;
00760 (*pos)->MarkExtensionAsProcessed(san2);
00761 }
00762
00763
00764 if((*pos)->AreThereAnyUnprocessedCriticalExtensions())
00765 {
00766 ERROR_OVERRIDE(PATH_UNPROCESSED_CRITICAL_EXTENSION);
00767 }
00768
00769
00770
00771 (*pos)->GetStatus()->SetPassedValidationChecks(true);
00772 }
00773
00774
00775
00776
00777 CPKIFPolicyInformationListPtr userSet(new CPKIFPolicyInformationList), initSet, authSetCondensed;
00778 results.GetAuthorityConstrainedSet(authSetCondensed);
00779
00780 if(settings != (CPKIFPathSettings*)NULL)
00781 settings->GetInitialPolicySet(initSet);
00782
00783 CPKIFPolicyInformationPtr anyPolicyPI(new CPKIFPolicyInformation(anyPolicy));
00784
00785 if(initSet != (CPKIFPolicyInformationList*)NULL && !initSet->empty() && *anyPolicyPI == *initSet->front())
00786 {
00787
00788
00789 userSet = authSetCondensed;
00790 }
00791 else if(authSetCondensed != (CPKIFPolicyInformationList*)NULL && !authSetCondensed->empty() && *anyPolicyPI == *authSetCondensed->front())
00792 {
00793
00794 userSet = initSet;
00795 }
00796 else if(initSet != (CPKIFPolicyInformationList*)NULL && !initSet->empty())
00797 {
00798
00799 IntersectSets(authSetCondensed, initSet, userSet);
00800 }
00801
00802 if(permSubtreesSet)
00803 results.SetPermittedSubtrees(permSubtrees);
00804 results.SetExcludedSubtrees(exclSubtrees);
00805 if(bPendingExplicitPolicy)
00806 results.SetPendingExplicitPolicy(nPendingExplicitPolicy);
00807 if(bPendingPolicyMapping)
00808 results.SetPendingPolicyMapping(nPendingPolicyMapping);
00809 if(bPendingAnyPolicy)
00810 results.SetPendingAnyPolicy(nPendingAnyPolicy);
00811 if(bPathLength)
00812 results.SetPendingPathLength(nPathLength);
00813
00814
00815 results.SetUserConstrainedSet(userSet);
00816 results.SetExplicitPolicyIndicator(indicators[CPKIFPathSettings::EXPLICIT_POLICY]);
00817
00818 if(isPathGood && indicators[CPKIFPathSettings::EXPLICIT_POLICY] && userSet->empty())
00819 {
00820
00821
00822
00823
00824 CPKIFCertificateNodeEntryPtr lastCert = certNodeList.back();
00825 bool override = false;
00826 bool (*fp) (int, CPKIFCertificatePtr&,const CPKIFCertificatePath&) = settings->GetOverrideCallback();
00827 if(NULL != fp)
00828 {
00829 CPKIFCertificatePtr tmpCert = lastCert->GetCert();
00830 if(fp(PATH_NULL_USER_POLICY_SET, tmpCert, path))
00831 override = true;
00832 }
00833 if(!override)
00834 {
00835 CPKIFCertStatusPtr status(new CPKIFCertStatus);
00836 status->SetDiagnosticCode(PATH_NULL_USER_POLICY_SET);
00837 lastCert->SetStatus(status);
00838 results.SetCertificate(lastCert);
00839 isPathGood = false;
00840 return false;
00841 }
00842
00843 }
00844
00845
00846
00847
00848 results.SetBasicChecksSuccessfullyPerformed(isPathGood);
00849
00850
00851 return isPathGood;
00852 }