Skip to content

Commit

Permalink
Bug 1593167, certdb: propagate trust information if trust module is l…
Browse files Browse the repository at this point in the history
…oaded afterwards, r=rrelyea,keeler

Summary:
When the builtin trust module is loaded after some temp certs being created, these temp certs are usually not accompanied by trust information. This causes a problem in Firefox as it loads the module from a separate thread while accessing the network cache which populates temp certs.

This change makes it properly roll up the trust information, if a temp cert doesn't have trust information.

Reviewers: rrelyea, keeler

Reviewed By: rrelyea, keeler

Subscribers: reviewbot, heftig

Bug #: 1593167

Differential Revision: https://phabricator.services.mozilla.com/D54726

--HG--
extra : rebase_source : 66168a158146268420b29c0dc4fac9ee0f5d71b5
extra : amend_source : 09141b330946a1df35403957711f4221ca0dd754
  • Loading branch information
ueno committed Dec 6, 2019
1 parent 6d8a852 commit 7b397c0
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions lib/pki/pki3hack.c
Expand Up @@ -921,14 +921,28 @@ stan_GetCERTCertificate(NSSCertificate *c, PRBool forceUpdate)
}
if (!cc->nssCertificate || forceUpdate) {
fill_CERTCertificateFields(c, cc, forceUpdate);
} else if (CERT_GetCertTrust(cc, &certTrust) != SECSuccess &&
!c->object.cryptoContext) {
/* if it's a perm cert, it might have been stored before the
* trust, so look for the trust again. But a temp cert can be
* ignored.
*/
CERTCertTrust *trust = NULL;
trust = nssTrust_GetCERTCertTrustForCert(c, cc);
} else if (CERT_GetCertTrust(cc, &certTrust) != SECSuccess) {
CERTCertTrust *trust;
if (!c->object.cryptoContext) {
/* If it's a perm cert, it might have been stored before the
* trust, so look for the trust again.
*/
trust = nssTrust_GetCERTCertTrustForCert(c, cc);
} else {
/* If it's a temp cert, it might have been stored before the
* builtin trust module is loaded, so look for the trust
* again, but don't set the empty trust if it is not found.
*/
NSSTrust *t = nssTrustDomain_FindTrustForCertificate(c->object.cryptoContext->td, c);
if (!t) {
goto loser;
}
trust = cert_trust_from_stan_trust(t, cc->arena);
nssTrust_Destroy(t);
if (!trust) {
goto loser;
}
}

CERT_LockCertTrust(cc);
cc->trust = trust;
Expand Down

0 comments on commit 7b397c0

Please sign in to comment.