diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-10-16 14:13:47 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2015-10-16 15:58:33 +0200 |
commit | 6952b457e2c8aa8b005055e91f5f93aaf293dfe4 (patch) | |
tree | b2dcb4d477fdbc75cedd1cbad292124a2f598975 /src/pkcs11.c | |
parent | f0033c9f2a89d14ff69fdc38f982c8f1a94a9570 (diff) | |
download | gnutls-6952b457e2c8aa8b005055e91f5f93aaf293dfe4.tar.gz |
p11tool: Allow writing a PKCS #11 pubkey object
Diffstat (limited to 'src/pkcs11.c')
-rw-r--r-- | src/pkcs11.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/pkcs11.c b/src/pkcs11.c index 5fbb4a9712..24edee0be3 100644 --- a/src/pkcs11.c +++ b/src/pkcs11.c @@ -636,6 +636,7 @@ pkcs11_write(FILE * outfile, const char *url, const char *label, { gnutls_x509_crt_t xcrt; gnutls_x509_privkey_t xkey; + gnutls_pubkey_t xpubkey; int ret; gnutls_datum_t *secret_key; unsigned key_usage = 0; @@ -706,9 +707,22 @@ pkcs11_write(FILE * outfile, const char *url, const char *label, } } - if (xkey == NULL && xcrt == NULL && secret_key == NULL) { + xpubkey = load_pubkey(0, info); + if (xpubkey != NULL) { + ret = + gnutls_pkcs11_copy_pubkey(url, xpubkey, label, + &cid, + 0, flags); + if (ret < 0) { + fprintf(stderr, "Error in %s:%d: %s\n", __func__, + __LINE__, gnutls_strerror(ret)); + exit(1); + } + } + + if (xkey == NULL && xcrt == NULL && secret_key == NULL && xpubkey == NULL) { fprintf(stderr, - "You must use --load-privkey, --load-certificate or --secret-key to load the file to be copied\n"); + "You must use --load-privkey, --load-certificate, --load-pubkey or --secret-key to load the file to be copied\n"); exit(1); } |