Manual Reference Pages - ZCERTSTORE (3)
zcertstore - work with CURVE security certificate stores
// Create a new certificate store from a disk directory, loading and
// indexing all certificates in that location. The directory itself may be
// absent, and created later, or modified at any time. The certificate store
// is automatically refreshed on any zcertstore_lookup() call. If the
// location is specified as NULL, creates a pure-memory store, which you
// can work with by inserting certificates at runtime.
CZMQ_EXPORT zcertstore_t *
zcertstore_new (const char *location);
// Destroy a certificate store object in memory. Does not affect anything
// stored on disk.
zcertstore_destroy (zcertstore_t **self_p);
// Look up certificate by public key, returns zcert_t object if found,
// else returns NULL. The public key is provided in Z85 text format.
CZMQ_EXPORT zcert_t *
zcertstore_lookup (zcertstore_t *self, const char *public_key);
// 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.
zcertstore_insert (zcertstore_t *self, zcert_t **cert_p);
// Print list of certificates in store to logging facility
zcertstore_print (zcertstore_t *self);
// DEPRECATED as incompatible with centralized logging
// Print list of certificates in store to open stream
zcertstore_fprint (zcertstore_t *self, FILE *file);
// Self test of this class
zcertstore_test (bool verbose);
To authenticate new clients using the ZeroMQ CURVE security mechanism, we have to check that the clients public key matches a key we know and accept. There are numerous ways to store accepted client public keys. The mechanism CZMQ implements is "certificates" (plain text files) held in a "certificate store" (a disk directory). This class works with such certificate stores, and lets you easily load them from disk, and check if a given client public key is known or not. The zcert class does the work of managing a single certificate.
The certificate store can be memory-only, in which case you can load it yourself by inserting certificate objects one by one, or it can be loaded from disk, in which case you can add, modify, or remove certificates on disk at any time, and the store will detect such changes and refresh itself automatically. In most applications you wont use this class directly but through the zauth class, which provides a high-level API for authentication (and manages certificate stores for you). To actually create certificates on disk, use the zcert class in code, or the tools/makecert.c command line tool, or any text editor. The format of a certificate file is defined in the zcert man page.
From zcertstore_test method.
// Create temporary directory for test files
# define TESTDIR ".test_zcertstore"
// Load certificate store from disk; it will be empty
zcertstore_t *certstore = zcertstore_new (TESTDIR);
// Create a single new certificate and save to disk
zcert_t *cert = zcert_new ();
char *client_key = strdup (zcert_public_txt (cert));
zcert_set_meta (cert, "name", "John Doe");
zcert_save (cert, TESTDIR "/mycert.txt");
// Check that certificate store refreshes as expected
cert = zcertstore_lookup (certstore, client_key);
assert (streq (zcert_meta (cert, "name"), "John Doe"));
// Delete all test files
zdir_t *dir = zdir_new (TESTDIR, NULL);
zdir_remove (dir, true);
The czmq manual was written by the authors in the AUTHORS file.
Main web site: [blue] 
Report bugs to the email <[blue]firstname.lastname@example.org>
Copyright (c) 1991-2012 iMatix Corporation -- http://www.imatix.com Copyright other contributors as noted in the AUTHORS file. This file is part of CZMQ, the high-level C binding for 0MQ: http://czmq.zeromq.org This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. LICENSE included with the czmq distribution.
|CZMQ 3&.0&.1 ||ZCERTSTORE (3) ||06/01/2015 |
Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.