From: Nikos Mavrogiannopoulos Date: Thu, 13 Oct 2016 14:41:04 +0000 (+0200) Subject: p11tool: improved messages on token initialization X-Git-Tag: gnutls_3_5_6~89 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4e43cbcf2b9e245973e12d7d17294e67d0d6834a;p=thirdparty%2Fgnutls.git p11tool: improved messages on token initialization --- diff --git a/src/pkcs11.c b/src/pkcs11.c index e590f67bf0..77002b9ee8 100644 --- a/src/pkcs11.c +++ b/src/pkcs11.c @@ -871,6 +871,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 { @@ -886,6 +891,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 { @@ -899,13 +914,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__,