diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-13 16:41:04 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2016-10-14 12:53:46 +0200 |
commit | 1e23101fdcbaab6030d5d1a6379d991b022f0778 (patch) | |
tree | 53fdc989a26cde812f849b2c0c1e034838f778c0 | |
parent | 0a85708fb0b4f661427a48003c12fbc760ceed2e (diff) | |
download | gnutls-1e23101fdcbaab6030d5d1a6379d991b022f0778.tar.gz |
p11tool: improved messages on token initialization
-rw-r--r-- | src/pkcs11.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/pkcs11.c b/src/pkcs11.c index 8c5cb09224..5f9dd82028 100644 --- a/src/pkcs11.c +++ b/src/pkcs11.c @@ -697,6 +697,11 @@ pkcs11_init(FILE * outfile, const char *url, const char *label, exit(1); } + if (label == NULL) { + fprintf(stderr, "error: no label provided for token initialization!\n"); + exit(1); + } + if (info->so_pin != NULL) pin = info->so_pin; else { @@ -712,6 +717,16 @@ pkcs11_init(FILE * outfile, const char *url, const char *label, strcpy(so_pin, pin); + fprintf(stderr, "Initializing token... "); + ret = gnutls_pkcs11_token_init(url, so_pin, label); + if (ret < 0) { + fprintf(stderr, "\nError in %s:%d: %s\n", __func__, __LINE__, + gnutls_strerror(ret)); + exit(1); + } + fprintf(stderr, "done\n"); + + fprintf(stderr, "Setting token's user PIN...\n"); if (info->pin != NULL) { pin = info->pin; } else { @@ -725,13 +740,6 @@ pkcs11_init(FILE * outfile, const char *url, const char *label, if (pin == NULL || pin[0] == '\n') exit(1); - ret = gnutls_pkcs11_token_init(url, so_pin, label); - if (ret < 0) { - fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, - gnutls_strerror(ret)); - exit(1); - } - ret = gnutls_pkcs11_token_set_pin(url, NULL, pin, GNUTLS_PIN_USER); if (ret < 0) { fprintf(stderr, "Error in %s:%d: %s\n", __func__, __LINE__, |