OLD | NEW |
1 /* This Source Code Form is subject to the terms of the Mozilla Public | 1 /* This Source Code Form is subject to the terms of the Mozilla Public |
2 * License, v. 2.0. If a copy of the MPL was not distributed with this | 2 * License, v. 2.0. If a copy of the MPL was not distributed with this |
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
4 | 4 |
5 /* | 5 /* |
6 * Hacks to integrate NSS 3.4 and NSS 4.0 certificates. | 6 * Hacks to integrate NSS 3.4 and NSS 4.0 certificates. |
7 */ | 7 */ |
8 | 8 |
9 #ifndef NSSPKI_H | 9 #ifndef NSSPKI_H |
10 #include "nsspki.h" | 10 #include "nsspki.h" |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 } | 221 } |
222 | 222 |
223 /* this function should not be a hack; it will be needed in 4.0 (rename) */ | 223 /* this function should not be a hack; it will be needed in 4.0 (rename) */ |
224 NSS_IMPLEMENT NSSItem * | 224 NSS_IMPLEMENT NSSItem * |
225 STAN_GetCertIdentifierFromDER(NSSArena *arenaOpt, NSSDER *der) | 225 STAN_GetCertIdentifierFromDER(NSSArena *arenaOpt, NSSDER *der) |
226 { | 226 { |
227 NSSItem *rvKey; | 227 NSSItem *rvKey; |
228 SECItem secDER; | 228 SECItem secDER; |
229 SECItem secKey = { 0 }; | 229 SECItem secKey = { 0 }; |
230 SECStatus secrv; | 230 SECStatus secrv; |
231 PRArenaPool *arena; | 231 PLArenaPool *arena; |
232 | 232 |
233 SECITEM_FROM_NSSITEM(&secDER, der); | 233 SECITEM_FROM_NSSITEM(&secDER, der); |
234 | 234 |
235 /* nss3 call uses nss3 arena's */ | 235 /* nss3 call uses nss3 arena's */ |
236 arena = PORT_NewArena(256); | 236 arena = PORT_NewArena(256); |
237 if (!arena) { | 237 if (!arena) { |
238 return NULL; | 238 return NULL; |
239 } | 239 } |
240 secrv = CERT_KeyFromDERCert(arena, &secDER, &secKey); | 240 secrv = CERT_KeyFromDERCert(arena, &secDER, &secKey); |
241 if (secrv != SECSuccess) { | 241 if (secrv != SECSuccess) { |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 ) | 543 ) |
544 { | 544 { |
545 CERTCertificate *cert = (CERTCertificate *)dc->data; | 545 CERTCertificate *cert = (CERTCertificate *)dc->data; |
546 | 546 |
547 /* The decoder may only be half initialized (the case where we find we | 547 /* The decoder may only be half initialized (the case where we find we |
548 * could not decode the certificate). In this case, there is not cert to | 548 * could not decode the certificate). In this case, there is not cert to |
549 * free, just free the dc structure. */ | 549 * free, just free the dc structure. */ |
550 if (cert) { | 550 if (cert) { |
551 PRBool freeSlot = cert->ownSlot; | 551 PRBool freeSlot = cert->ownSlot; |
552 PK11SlotInfo *slot = cert->slot; | 552 PK11SlotInfo *slot = cert->slot; |
553 » PRArenaPool *arena = cert->arena; | 553 » PLArenaPool *arena = cert->arena; |
554 /* zero cert before freeing. Any stale references to this cert | 554 /* zero cert before freeing. Any stale references to this cert |
555 * after this point will probably cause an exception. */ | 555 * after this point will probably cause an exception. */ |
556 PORT_Memset(cert, 0, sizeof *cert); | 556 PORT_Memset(cert, 0, sizeof *cert); |
557 /* free the arena that contains the cert. */ | 557 /* free the arena that contains the cert. */ |
558 PORT_FreeArena(arena, PR_FALSE); | 558 PORT_FreeArena(arena, PR_FALSE); |
559 if (slot && freeSlot) { | 559 if (slot && freeSlot) { |
560 PK11_FreeSlot(slot); | 560 PK11_FreeSlot(slot); |
561 } | 561 } |
562 } | 562 } |
563 nss_ZFreeIf(dc); | 563 nss_ZFreeIf(dc); |
(...skipping 14 matching lines...) Expand all Loading... |
578 if (t == nssTrustLevel_NotTrusted) { | 578 if (t == nssTrustLevel_NotTrusted) { |
579 rt |= CERTDB_TERMINAL_RECORD; | 579 rt |= CERTDB_TERMINAL_RECORD; |
580 } | 580 } |
581 if (t == nssTrustLevel_ValidDelegator) { | 581 if (t == nssTrustLevel_ValidDelegator) { |
582 rt |= CERTDB_VALID_CA; | 582 rt |= CERTDB_VALID_CA; |
583 } | 583 } |
584 return rt; | 584 return rt; |
585 } | 585 } |
586 | 586 |
587 static CERTCertTrust * | 587 static CERTCertTrust * |
588 cert_trust_from_stan_trust(NSSTrust *t, PRArenaPool *arena) | 588 cert_trust_from_stan_trust(NSSTrust *t, PLArenaPool *arena) |
589 { | 589 { |
590 CERTCertTrust *rvTrust; | 590 CERTCertTrust *rvTrust; |
591 unsigned int client; | 591 unsigned int client; |
592 if (!t) { | 592 if (!t) { |
593 return NULL; | 593 return NULL; |
594 } | 594 } |
595 rvTrust = PORT_ArenaAlloc(arena, sizeof(CERTCertTrust)); | 595 rvTrust = PORT_ArenaAlloc(arena, sizeof(CERTCertTrust)); |
596 if (!rvTrust) return NULL; | 596 if (!rvTrust) return NULL; |
597 rvTrust->sslFlags = get_nss3trust_from_nss4trust(t->serverAuth); | 597 rvTrust->sslFlags = get_nss3trust_from_nss4trust(t->serverAuth); |
598 client = get_nss3trust_from_nss4trust(t->clientAuth); | 598 client = get_nss3trust_from_nss4trust(t->clientAuth); |
(...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1422 td = STAN_GetDefaultTrustDomain(); | 1422 td = STAN_GetDefaultTrustDomain(); |
1423 cc = STAN_GetDefaultCryptoContext(); | 1423 cc = STAN_GetDefaultCryptoContext(); |
1424 printf("\n\nCertificates in the cache:\n"); | 1424 printf("\n\nCertificates in the cache:\n"); |
1425 nssTrustDomain_DumpCacheInfo(td, cert_dump_iter, NULL); | 1425 nssTrustDomain_DumpCacheInfo(td, cert_dump_iter, NULL); |
1426 printf("\n\nCertificates in the temporary store:\n"); | 1426 printf("\n\nCertificates in the temporary store:\n"); |
1427 if (cc->certStore) { | 1427 if (cc->certStore) { |
1428 nssCertificateStore_DumpStoreInfo(cc->certStore, cert_dump_iter, NULL); | 1428 nssCertificateStore_DumpStoreInfo(cc->certStore, cert_dump_iter, NULL); |
1429 } | 1429 } |
1430 } | 1430 } |
1431 | 1431 |
OLD | NEW |