int zcert_save (zcert_t *self, char *format, ...) { assert (self); assert (format); va_list argptr; va_start (argptr, format); char *filename = zsys_vprintf (format, argptr); va_end (argptr); // Save public certificate using specified filename zcert_save_public (self, filename); // Now save secret certificate using filename with "_secret" suffix s_save_metadata_all (self); zconfig_comment (self->config, " ZeroMQ CURVE **Secret** Certificate"); zconfig_comment (self->config, " DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions."); zconfig_put (self->config, "/curve/public-key", self->public_txt); zconfig_put (self->config, "/curve/secret-key", self->secret_txt); char filename_secret [256]; snprintf (filename_secret, 256, "%s_secret", filename); zsys_file_mode_private (); int rc = zconfig_save (self->config, filename_secret); zsys_file_mode_default (); zstr_free (&filename); return rc; }
int zcert_save_secret (zcert_t *self, const char *filename) { assert (self); assert (filename); s_save_metadata_all (self); zconfig_set_comment (self->config, " ZeroMQ CURVE **Secret** Certificate"); zconfig_set_comment (self->config, " DO NOT PROVIDE THIS FILE TO OTHER USERS nor change its permissions."); zconfig_put (self->config, "/curve/public-key", self->public_txt); zconfig_put (self->config, "/curve/secret-key", self->secret_txt); zsys_file_mode_private (); int rc = zconfig_save (self->config, filename); zsys_file_mode_default (); return rc; }
int zcert_save_public (zcert_t *self, const char *filename) { assert (self); assert (filename); s_save_metadata_all (self); zconfig_set_comment (self->config, " ZeroMQ CURVE Public Certificate"); zconfig_set_comment (self->config, " Exchange securely, or use a secure mechanism to verify the contents"); zconfig_set_comment (self->config, " of this file after exchange. Store public certificates in your home"); zconfig_set_comment (self->config, " directory, in the .curve subdirectory."); zconfig_put (self->config, "/curve/public-key", self->public_txt); int rc = zconfig_save (self->config, filename); return rc; }
int zcert_save_public (zcert_t *self, char *format, ...) { assert (self); assert (format); va_list argptr; va_start (argptr, format); char *filename = zsys_vprintf (format, argptr); va_end (argptr); s_save_metadata_all (self); zconfig_comment (self->config, " ZeroMQ CURVE Public Certificate"); zconfig_comment (self->config, " Exchange securely, or use a secure mechanism to verify the contents"); zconfig_comment (self->config, " of this file after exchange. Store public certificates in your home"); zconfig_comment (self->config, " directory, in the .curve subdirectory."); zconfig_put (self->config, "/curve/public-key", self->public_txt); int rc = zconfig_save (self->config, filename); zstr_free (&filename); return rc; }