comparison cinst/mozilla.c @ 309:fa37384b86b6

Add trust "Trusted CA to issue server certificates" to certs on install.
author Sascha Wilde <wilde@intevation.de>
date Fri, 04 Apr 2014 09:53:55 +0200
parents ab69d268b5c8
children 4ffc9f31b61a
comparison
equal deleted inserted replaced
308:ab69d268b5c8 309:fa37384b86b6
413 */ 413 */
414 static bool 414 static bool
415 import_cert(char *pdir, SECItem *dercert) 415 import_cert(char *pdir, SECItem *dercert)
416 { 416 {
417 PK11SlotInfo *pk11slot = NULL; 417 PK11SlotInfo *pk11slot = NULL;
418 CERTCertTrust *trust = NULL;
419 CERTCertificate *cert = NULL;
418 bool success = false; 420 bool success = false;
419 char *cert_name = nss_cert_name(dercert); 421 char *cert_name = nss_cert_name(dercert);
420 422
421 DEBUGPRINTF("INSTALLING cert: '%s' to: %s\n", cert_name, pdir); 423 DEBUGPRINTF("INSTALLING cert: '%s' to: %s\n", cert_name, pdir);
422 if (NSS_Initialize(pdir, "", "", "secmod.db", 0) == SECSuccess) 424 if (NSS_Initialize(pdir, "", "", "secmod.db", 0) == SECSuccess)
423 { 425 {
424 pk11slot = PK11_GetInternalKeySlot(); 426 pk11slot = PK11_GetInternalKeySlot();
425 if (PK11_ImportDERCert(pk11slot, dercert, CK_INVALID_HANDLE, 427 cert = CERT_DecodeCertFromPackage((char *)dercert->data,
426 cert_name, PR_FALSE) 428 (int)dercert->len);
427 == SECSuccess) 429 trust = (CERTCertTrust *)xmalloc(sizeof(CERTCertTrust));
428 { 430 CERT_DecodeTrustString(trust, "C");
431 if ((PK11_ImportCert(pk11slot, cert, CK_INVALID_HANDLE,
432 cert_name, PR_FALSE)
433 == SECSuccess) &&
434 (CERT_ChangeCertTrust(CERT_GetDefaultCertDB(), cert, trust)
435 == SECSuccess))
436 {
437
429 success = true; 438 success = true;
430 } 439 }
431 else 440 else
432 { 441 {
433 DEBUGPRINTF("Failed to install certificate '%s' to '%s'!\n", cert_name, pdir); 442 DEBUGPRINTF("Failed to install certificate '%s' to '%s'!\n", cert_name, pdir);
434 } 443 }
444 CERT_DestroyCertificate (cert);
445 PORT_Free(trust);
435 PK11_FreeSlot(pk11slot); 446 PK11_FreeSlot(pk11slot);
436 NSS_Shutdown(); 447 NSS_Shutdown();
437 } 448 }
438 else 449 else
439 { 450 {

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