static void s_load_certs_from_disk (zcertstore_t *self) { s_empty_store (self); zdir_t *dir = zdir_new (self->location, NULL); if (dir) { // Load all certificates including those in subdirectories zfile_t **filelist = zdir_flatten (dir); uint index; for (index = 0;; index++) { zfile_t *file = filelist [index]; if (!file) break; // End of list if (zfile_is_regular (file)) { zcert_t *cert = zcert_load (zfile_filename (file, NULL)); if (cert) zcertstore_insert (self, &cert); } } zdir_flatten_free (&filelist); self->modified = zdir_modified (dir); self->count = zdir_count (dir); self->cursize = zdir_cursize (dir); zdir_destroy (&dir); } }
static void s_test_loader (zcertstore_t *certstore) { zcertstore_empty (certstore); byte public_key [32] = { 31, 133, 154, 36, 47, 67, 155, 5, 63, 1, 155, 230, 78, 191, 156, 199, 94, 125, 157, 168, 109, 69, 19, 241, 44, 29, 154, 216, 59, 219, 155, 185 }; byte secret_key [32] = { 31, 133, 154, 36, 47, 67, 155, 5, 63, 1, 155, 230, 78, 191, 156, 199, 94, 125, 157, 168, 109, 69, 19, 241, 44, 29, 154, 216, 59, 219, 155, 185 }; zcert_t *cert = zcert_new_from (public_key, secret_key); zcertstore_insert (certstore, &cert); test_loader_state *state = (test_loader_state *)certstore->state; state->index++; }
static void s_disk_loader (zcertstore_t *certstore) { disk_loader_state *state = (disk_loader_state *)certstore->state; zdir_t *dir = zdir_new (state->location, NULL); if (dir && (state->modified != zdir_modified (dir) || state->count != zdir_count (dir) || state->cursize != (size_t) zdir_cursize (dir))) { zhashx_purge (certstore->certs); // Load all certificates including those in subdirectories zfile_t **filelist = zdir_flatten (dir); assert (filelist); zrex_t *rex = zrex_new ("_secret$"); assert (rex); uint index; for (index = 0;; index++) { zfile_t *file = filelist [index]; if (!file) break; // End of list if (zfile_is_regular (file) && !zrex_matches (rex, zfile_filename (file, NULL))) { zcert_t *cert = zcert_load (zfile_filename (file, NULL)); if (cert) zcertstore_insert (certstore, &cert); } } zdir_flatten_free (&filelist); state->modified = zdir_modified (dir); state->count = zdir_count (dir); state->cursize = zdir_cursize (dir); zrex_destroy (&rex); } zdir_destroy (&dir); }
/// // Insert certificate into certificate store in memory. Note that this // does not save the certificate to disk. To do that, use zcert_save() // directly on the certificate. Takes ownership of zcert_t object. void QmlZcertstore::insert (QmlZcert *certP) { zcertstore_insert (self, &certP->self); };
JNIEXPORT void JNICALL Java_org_zeromq_czmq_Zcertstore__1_1insert (JNIEnv *env, jclass c, jlong self, jlong cert_p) { zcertstore_insert ((zcertstore_t *) (intptr_t) self, (zcert_t **) (intptr_t) &cert_p); }