comparison cinst/mozilla.c @ 269:f7471604bb31

Deletion of certificates implemented. We are feature complete! Only some cleanup, refactoring and stabilisation to do...
author Sascha Wilde <wilde@intevation.de>
date Wed, 02 Apr 2014 10:30:49 +0200
parents a7c6a21aba38
children ea9c5bbc6496
comparison
equal deleted inserted replaced
268:a7c6a21aba38 269:f7471604bb31
41 #define _POSIX_C_SOURCE 200809L 41 #define _POSIX_C_SOURCE 200809L
42 42
43 /* REMOVEME: */ 43 /* REMOVEME: */
44 #include <unistd.h> 44 #include <unistd.h>
45 45
46 #include <cert.h>
47 #include <certdb.h>
48 #include <certt.h>
46 #include <dirent.h> 49 #include <dirent.h>
47 #include <cert.h>
48 #include <certt.h>
49 #include <nss.h> 50 #include <nss.h>
50 #include <pk11pub.h> 51 #include <pk11pub.h>
51 #include <stdbool.h> 52 #include <stdbool.h>
52 #include <stdio.h> 53 #include <stdio.h>
53 #include <stdlib.h> 54 #include <stdlib.h>
444 seciteml_t *certs_to_add = NULL; 445 seciteml_t *certs_to_add = NULL;
445 SECItem *secitemp; 446 SECItem *secitemp;
446 SECStatus rv; 447 SECStatus rv;
447 PK11SlotInfo *pk11slot = NULL; 448 PK11SlotInfo *pk11slot = NULL;
448 char *cert_name; 449 char *cert_name;
450 CERTCertificate *cert = NULL;
449 451
450 pdirs = 452 pdirs =
451 get_all_profile_dirs(); 453 get_all_profile_dirs();
452 454
453 if (pdirs != NULL) 455 if (pdirs != NULL)
455 parse_commands(&certs_to_add, &certs_to_remove); 457 parse_commands(&certs_to_add, &certs_to_remove);
456 458
457 while ((secitemp = seciteml_pop(&certs_to_remove)) != NULL) 459 while ((secitemp = seciteml_pop(&certs_to_remove)) != NULL)
458 { 460 {
459 cert_name = nss_cert_name(secitemp); 461 cert_name = nss_cert_name(secitemp);
460 printf("Request to REMOVE cert: %s\n", cert_name); 462 for (int i=0; pdirs[i] != NULL; i++)
463 {
464 puts(pdirs[i]);
465 nss_list_certs(pdirs[i]);
466
467 printf("Will now DELETE cert: '%s' from %s\n", cert_name, pdirs[i]);
468 if (NSS_Initialize(pdirs[i], "", "", "secmod.db", 0)
469 == SECSuccess)
470 {
471 pk11slot = PK11_GetInternalKeySlot();
472 cert = PK11_FindCertFromDERCertItem(pk11slot,
473 secitemp, NULL);
474 if (cert != NULL)
475 {
476 rv = SEC_DeletePermCertificate(cert);
477 if (rv != SECSuccess)
478 {
479 DEBUGPRINTF("Failed to remove certificate '%s' from '%s'!\n", cert_name, pdirs[i]);
480 DEBUGPRINTF("Error was %d\n", rv);
481 }
482 }
483 else
484 {
485 DEBUGPRINTF("Could not find Certificate %s in store.\n", cert_name);
486 }
487 CERT_DestroyCertificate(cert);
488 PK11_FreeSlot(pk11slot);
489 NSS_Shutdown();
490 }
491 puts("List new:");
492 nss_list_certs(pdirs[i]);
493 }
461 free(cert_name); 494 free(cert_name);
462 free(secitemp->data); 495 free(secitemp->data);
463 free(secitemp); 496 free(secitemp);
464 } 497 }
465 498

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