Lines Matching refs:keystore
101 keystore_passphrase_cb cb, keystore_t *keystore);
131 keystore_t *keystore = keystore_h; in print_certs() local
133 if (keystore->clcerts != NULL) { in print_certs()
135 for (i = 0; i < sk_X509_num(keystore->clcerts); i++) { in print_certs()
136 cert = sk_X509_value(keystore->clcerts, i); in print_certs()
168 if (keystore->cacerts != NULL) { in print_certs()
170 for (i = 0; i < sk_X509_num(keystore->cacerts); i++) { in print_certs()
171 cert = sk_X509_value(keystore->cacerts, i); in print_certs()
210 alias, keystore->path); in print_certs()
214 keystore->path); in print_certs()
217 keystore->path); in print_certs()
466 free_keystore(keystore_t *keystore) in free_keystore() argument
468 if (keystore->path != NULL) in free_keystore()
469 free(keystore->path); in free_keystore()
470 if (keystore->capath != NULL) in free_keystore()
471 free(keystore->capath); in free_keystore()
472 if (keystore->passphrase != NULL) in free_keystore()
473 free(keystore->passphrase); in free_keystore()
474 if (keystore->clpath != NULL) in free_keystore()
475 free(keystore->clpath); in free_keystore()
476 if (keystore->keypath != NULL) in free_keystore()
477 free(keystore->keypath); in free_keystore()
479 if (keystore->pkeys != NULL) { in free_keystore()
480 sk_EVP_PKEY_pop_free(keystore->pkeys, in free_keystore()
483 if (keystore->clcerts != NULL) in free_keystore()
484 sk_X509_free(keystore->clcerts); in free_keystore()
485 if (keystore->cacerts != NULL) in free_keystore()
486 sk_X509_free(keystore->cacerts); in free_keystore()
487 free(keystore); in free_keystore()
508 keystore_t *keystore = keystore_h; in close_keystore() local
510 if (keystore->dirty) { in close_keystore()
512 if (!write_keystore(err, keystore, cb)) { in close_keystore()
515 keystore->path); in close_keystore()
521 if (!unlock_keystore(err, keystore)) { in close_keystore()
523 keystore->path); in close_keystore()
528 free_keystore(keystore); in close_keystore()
554 keystore_t *keystore = keystore_h; in merge_ca_cert() local
572 if (keystore->cacerts == NULL) { in merge_ca_cert()
574 if ((keystore->cacerts = sk_X509_new_null()) == NULL) { in merge_ca_cert()
581 if (sunw_find_fname(fname, NULL, keystore->cacerts, in merge_ca_cert()
600 (void) sk_X509_push(keystore->cacerts, cacert); in merge_ca_cert()
601 keystore->dirty = B_TRUE; in merge_ca_cert()
781 keystore_t *keystore = keystore_h; in merge_cert_and_key() local
797 if (keystore->clcerts == NULL) { in merge_cert_and_key()
799 if ((keystore->clcerts = sk_X509_new_null()) == NULL) { in merge_cert_and_key()
806 if (sunw_find_fname(alias, NULL, keystore->clcerts, in merge_cert_and_key()
825 if (keystore->pkeys == NULL) { in merge_cert_and_key()
827 if ((keystore->pkeys = sk_EVP_PKEY_new_null()) == NULL) { in merge_cert_and_key()
834 if (sunw_find_fname(alias, keystore->pkeys, NULL, in merge_cert_and_key()
853 (void) sk_X509_push(keystore->clcerts, cert); in merge_cert_and_key()
854 (void) sk_EVP_PKEY_push(keystore->pkeys, key); in merge_cert_and_key()
855 keystore->dirty = B_TRUE; in merge_cert_and_key()
1096 verify_keystore_integrity(PKG_ERR *err, keystore_t *keystore) in verify_keystore_integrity() argument
1098 if (keystore->capath != NULL) { in verify_keystore_integrity()
1099 if (!restore_keystore_file(err, keystore->capath)) { in verify_keystore_integrity()
1103 if (keystore->clpath != NULL) { in verify_keystore_integrity()
1104 if (!restore_keystore_file(err, keystore->clpath)) { in verify_keystore_integrity()
1108 if (keystore->keypath != NULL) { in verify_keystore_integrity()
1109 if (!restore_keystore_file(err, keystore->keypath)) { in verify_keystore_integrity()
1320 long flags, keystore_t *keystore) in resolve_paths() argument
1396 keystore->capath = xstrdup(storepath); in resolve_paths()
1399 keystore->clpath = xstrdup(storepath); in resolve_paths()
1402 keystore->keypath = xstrdup(storepath); in resolve_paths()
1407 keystore->capath = xstrdup(keystore_file); in resolve_paths()
1408 keystore->keypath = NULL; in resolve_paths()
1409 keystore->clpath = NULL; in resolve_paths()
1414 keystore->capath = xstrdup(storepath); in resolve_paths()
1417 keystore->clpath = xstrdup(storepath); in resolve_paths()
1420 keystore->keypath = xstrdup(storepath); in resolve_paths()
1463 lock_keystore(PKG_ERR *err, long flags, keystore_t *keystore) in lock_keystore() argument
1470 if ((keystore->cafd = in lock_keystore()
1471 open(keystore->capath, O_NONBLOCK|O_RDONLY)) == -1) { in lock_keystore()
1480 if ((keystore->cafd = in lock_keystore()
1481 open(keystore->capath, in lock_keystore()
1486 keystore->capath); in lock_keystore()
1493 keystore->capath, strerror(errno)); in lock_keystore()
1498 if (fstat(keystore->cafd, &buf) != -1) { in lock_keystore()
1500 if (file_lock(keystore->cafd, F_RDLCK, in lock_keystore()
1504 keystore->capath); in lock_keystore()
1512 keystore->capath); in lock_keystore()
1519 keystore->capath, strerror(errno)); in lock_keystore()
1526 if ((keystore->cafd = open(keystore->capath, in lock_keystore()
1530 if ((keystore->cafd = in lock_keystore()
1531 open(keystore->capath, in lock_keystore()
1536 keystore->capath); in lock_keystore()
1543 keystore->capath, strerror(errno)); in lock_keystore()
1548 if (fstat(keystore->cafd, &buf) != -1) { in lock_keystore()
1550 if (file_lock(keystore->cafd, F_WRLCK, in lock_keystore()
1554 keystore->capath); in lock_keystore()
1562 keystore->capath); in lock_keystore()
1569 keystore->capath, strerror(errno)); in lock_keystore()
1585 if (keystore->cafd > 0) { in lock_keystore()
1586 (void) file_unlock(keystore->cafd); in lock_keystore()
1587 (void) close(keystore->cafd); in lock_keystore()
1588 keystore->cafd = -1; in lock_keystore()
1591 if (keystore->capath != NULL) in lock_keystore()
1592 free(keystore->capath); in lock_keystore()
1593 if (keystore->clpath != NULL) in lock_keystore()
1594 free(keystore->clpath); in lock_keystore()
1595 if (keystore->keypath != NULL) in lock_keystore()
1596 free(keystore->keypath); in lock_keystore()
1597 keystore->capath = NULL; in lock_keystore()
1598 keystore->clpath = NULL; in lock_keystore()
1599 keystore->keypath = NULL; in lock_keystore()
1617 unlock_keystore(PKG_ERR *err, keystore_t *keystore) in unlock_keystore() argument
1624 if (file_empty(keystore->capath)) { in unlock_keystore()
1625 (void) remove(keystore->capath); in unlock_keystore()
1628 (void) file_unlock(keystore->cafd); in unlock_keystore()
1629 (void) close(keystore->cafd); in unlock_keystore()
1647 read_keystore(PKG_ERR *err, keystore_t *keystore, keystore_passphrase_cb cb) in read_keystore() argument
1656 ca_empty = file_empty(keystore->capath); in read_keystore()
1658 if (keystore->clpath != NULL) in read_keystore()
1659 cl_empty = file_empty(keystore->clpath); in read_keystore()
1660 if (keystore->keypath != NULL) in read_keystore()
1661 key_empty = file_empty(keystore->keypath); in read_keystore()
1664 keystore->new = B_TRUE; in read_keystore()
1670 keystore->capath)) == NULL) { in read_keystore()
1672 gettext(ERR_KEYSTORE_CORRUPT), keystore->capath); in read_keystore()
1679 if (!get_keystore_passwd(err, p12, cb, keystore)) { in read_keystore()
1687 if (sunw_PKCS12_contents(p12, keystore->passphrase, in read_keystore()
1688 &keystore->pkeys, &keystore->cacerts) < 0) { in read_keystore()
1691 gettext(ERR_KEYSTORE_CORRUPT), keystore->capath); in read_keystore()
1704 keystore->cacerts = NULL; in read_keystore()
1711 if (keystore->clpath == NULL && !ca_empty) { in read_keystore()
1712 if (sunw_split_certs(keystore->pkeys, keystore->cacerts, in read_keystore()
1713 &keystore->clcerts, NULL) < 0) { in read_keystore()
1715 gettext(ERR_KEYSTORE_CORRUPT), keystore->capath); in read_keystore()
1726 keystore->clpath)) == NULL) { in read_keystore()
1729 keystore->clpath); in read_keystore()
1737 keystore)) { in read_keystore()
1745 keystore->passphrase) == B_FALSE) { in read_keystore()
1753 keystore->clpath, in read_keystore()
1754 keystore->capath, keystore->path); in read_keystore()
1759 if (sunw_PKCS12_contents(p12, keystore->passphrase, in read_keystore()
1760 NULL, &keystore->clcerts) < 0) { in read_keystore()
1764 keystore->clpath); in read_keystore()
1772 keystore->clcerts = NULL; in read_keystore()
1777 keystore->keypath)) == NULL) { in read_keystore()
1780 keystore->keypath); in read_keystore()
1788 keystore)) { in read_keystore()
1796 keystore->passphrase) == B_FALSE) { in read_keystore()
1799 keystore->keypath, in read_keystore()
1800 keystore->capath, keystore->path); in read_keystore()
1805 if (sunw_PKCS12_contents(p12, keystore->passphrase, in read_keystore()
1806 &keystore->pkeys, NULL) < 0) { in read_keystore()
1810 keystore->keypath); in read_keystore()
1818 keystore->pkeys = NULL; in read_keystore()
1846 keystore_t *keystore) in get_keystore_passwd() argument
1879 keystore->passphrase = passwd; in get_keystore_passwd()
1896 write_keystore(PKG_ERR *err, keystore_t *keystore, in write_keystore() argument
1904 if (keystore->capath != NULL && keystore->clpath == NULL && in write_keystore()
1905 keystore->keypath == NULL) { in write_keystore()
1911 if ((keystore->pkeys == NULL) && in write_keystore()
1912 (keystore->clcerts == NULL) && in write_keystore()
1913 (keystore->cacerts == NULL)) { in write_keystore()
1914 if (!clear_keystore_file(err, keystore->capath)) { in write_keystore()
1924 keystore->capath); in write_keystore()
1933 if (keystore->new) { in write_keystore()
1945 (void) strlcpy(passbuf, keystore->passphrase, in write_keystore()
1949 p12 = sunw_PKCS12_create(passbuf, keystore->pkeys, in write_keystore()
1950 keystore->clcerts, keystore->cacerts); in write_keystore()
1955 keystore->capath); in write_keystore()
1960 if (!write_keystore_file(err, keystore->capath, p12)) { in write_keystore()
1963 keystore->capath); in write_keystore()
1976 if (keystore->new && ((keystore->pkeys != NULL) || in write_keystore()
1977 (keystore->clcerts != NULL) || in write_keystore()
1978 (keystore->cacerts != NULL))) { in write_keystore()
1987 (void) strlcpy(passbuf, keystore->passphrase, in write_keystore()
1992 if (keystore->pkeys != NULL) { in write_keystore()
1993 p12 = sunw_PKCS12_create(passbuf, keystore->pkeys, in write_keystore()
1999 keystore->keypath); in write_keystore()
2004 if (!write_keystore_file(err, keystore->keypath, in write_keystore()
2008 keystore->keypath); in write_keystore()
2015 if ((remove(keystore->keypath) != 0) && in write_keystore()
2019 keystore->keypath); in write_keystore()
2026 if (keystore->clcerts != NULL) { in write_keystore()
2028 keystore->clcerts, NULL); in write_keystore()
2033 keystore->clpath); in write_keystore()
2038 if (!write_keystore_file(err, keystore->clpath, p12)) { in write_keystore()
2041 keystore->clpath); in write_keystore()
2048 if ((remove(keystore->clpath) != 0) && in write_keystore()
2052 keystore->clpath); in write_keystore()
2060 if (keystore->cacerts != NULL) { in write_keystore()
2062 NULL, keystore->cacerts); in write_keystore()
2067 keystore->capath); in write_keystore()
2072 if (!write_keystore_file(err, keystore->capath, p12)) { in write_keystore()
2075 keystore->capath); in write_keystore()
2087 if (!clear_keystore_file(err, keystore->capath)) { in write_keystore()
2090 keystore->capath); in write_keystore()