comparison cinst/mozilla.c @ 268:a7c6a21aba38

Simplification, import DER cert directly to store.
author Sascha Wilde <wilde@intevation.de>
date Tue, 01 Apr 2014 19:10:05 +0200
parents 1fa607af6332
children f7471604bb31
comparison
equal deleted inserted replaced
264:daad3431b930 268:a7c6a21aba38
443 seciteml_t *certs_to_remove = NULL; 443 seciteml_t *certs_to_remove = NULL;
444 seciteml_t *certs_to_add = NULL; 444 seciteml_t *certs_to_add = NULL;
445 SECItem *secitemp; 445 SECItem *secitemp;
446 SECStatus rv; 446 SECStatus rv;
447 PK11SlotInfo *pk11slot = NULL; 447 PK11SlotInfo *pk11slot = NULL;
448 CERTCertificate *cert = NULL;
449 char *cert_name; 448 char *cert_name;
450 449
451 pdirs = 450 pdirs =
452 get_all_profile_dirs(); 451 get_all_profile_dirs();
453 452
475 printf("Will now ADD cert: '%s' to %s\n", cert_name, pdirs[i]); 474 printf("Will now ADD cert: '%s' to %s\n", cert_name, pdirs[i]);
476 if (NSS_Initialize(pdirs[i], "", "", "secmod.db", 0) 475 if (NSS_Initialize(pdirs[i], "", "", "secmod.db", 0)
477 == SECSuccess) 476 == SECSuccess)
478 { 477 {
479 pk11slot = PK11_GetInternalKeySlot(); 478 pk11slot = PK11_GetInternalKeySlot();
480 cert = CERT_DecodeCertFromPackage((char *)secitemp->data, (int)secitemp->len); 479 rv = PK11_ImportDERCert(pk11slot, secitemp, CK_INVALID_HANDLE, cert_name, PR_FALSE);
481 rv = PK11_ImportCert(pk11slot, cert, CK_INVALID_HANDLE, cert_name, PR_FALSE);
482 if (rv != SECSuccess) { 480 if (rv != SECSuccess) {
483 DEBUGPRINTF("Failed to install certificate '%s' to '%s'!\n", cert_name, pdirs[i]); 481 DEBUGPRINTF("Failed to install certificate '%s' to '%s'!\n", cert_name, pdirs[i]);
484 DEBUGPRINTF("Error was %d\n", rv); 482 DEBUGPRINTF("Error was %d\n", rv);
485 } 483 }
486 CERT_DestroyCertificate(cert);
487 cert = NULL;
488 PK11_FreeSlot(pk11slot); 484 PK11_FreeSlot(pk11slot);
489 NSS_Shutdown(); 485 NSS_Shutdown();
490 } 486 }
491 puts("List new:"); 487 puts("List new:");
492 nss_list_certs(pdirs[i]); 488 nss_list_certs(pdirs[i]);

http://wald.intevation.org/projects/trustbridge/