support output passphrases for copy certificate

This commit is contained in:
Love Hornquist Astrand
2009-09-29 11:28:12 -07:00
parent 50de7c4203
commit 0e762f8689

View File

@@ -777,31 +777,40 @@ int
certificate_copy(struct certificate_copy_options *opt, int argc, char **argv) certificate_copy(struct certificate_copy_options *opt, int argc, char **argv)
{ {
hx509_certs certs; hx509_certs certs;
hx509_lock lock; hx509_lock inlock, outlock = NULL;
int ret; int ret;
hx509_lock_init(context, &lock); hx509_lock_init(context, &inlock);
lock_strings(lock, &opt->in_pass_strings); lock_strings(inlock, &opt->in_pass_strings);
if (opt->out_pass_string) {
hx509_lock_init(context, &outlock);
ret = hx509_lock_command_string(outlock, opt->out_pass_string);
if (ret)
errx(1, "hx509_lock_command_string: %s: %d",
opt->out_pass_string, ret);
}
ret = hx509_certs_init(context, argv[argc - 1], ret = hx509_certs_init(context, argv[argc - 1],
HX509_CERTS_CREATE, lock, &certs); HX509_CERTS_CREATE, inlock, &certs);
if (ret) if (ret)
hx509_err(context, 1, ret, "hx509_certs_init"); hx509_err(context, 1, ret, "hx509_certs_init");
while(argc-- > 1) { while(argc-- > 1) {
int ret; int ret;
ret = hx509_certs_append(context, certs, lock, argv[0]); ret = hx509_certs_append(context, certs, inlock, argv[0]);
if (ret) if (ret)
hx509_err(context, 1, ret, "hx509_certs_append"); hx509_err(context, 1, ret, "hx509_certs_append");
argv++; argv++;
} }
ret = hx509_certs_store(context, certs, 0, NULL); ret = hx509_certs_store(context, certs, 0, outlock);
if (ret) if (ret)
hx509_err(context, 1, ret, "hx509_certs_store"); hx509_err(context, 1, ret, "hx509_certs_store");
hx509_certs_free(&certs); hx509_certs_free(&certs);
hx509_lock_free(lock); hx509_lock_free(inlock);
hx509_lock_free(outlock);
return 0; return 0;
} }