- if((crtn == CSSM_OK) && (nonRootIssuer == NULL)) {
- if(!issuerCert->isSelfSigned()) {
- /*
- * Exact value not important here, this just uniquely identifies
- * this situation in the switch below.
- */
- tpDbDebug("tpDbFindIssuerCert: holding non-root cert (1)");
- crtn = CSSM_CERT_STATUS_IS_ROOT;
+ if(crtn == CSSM_OK && !issuerCert->isSelfSigned()) {
+ /*
+ * Exact value not important here, this just uniquely identifies
+ * this situation in the switch below.
+ */
+ tpDbDebug("tpDbFindIssuerCert: holding non-root cert (1)");
+ crtn = CSSM_CERT_STATUS_IS_ROOT;
+ /*
+ * If the old intermediate was temporally invalid, replace it.
+ * (Regardless of temporal validity of new one we found, because
+ * as far as this code is concerned they're equivalent.)
+ */
+ if(!nonRootIssuer ||
+ (nonRootIssuer && (nonRootIssuer->isExpired() || nonRootIssuer->isNotValidYet()))) {
+ if(nonRootIssuer) {
+ nonRootIssuer->freeUniqueRecord();
+ delete nonRootIssuer;
+ }