summaryrefslogtreecommitdiff
path: root/src/pkcs11.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@redhat.com>2016-10-13 16:41:04 +0200
committerNikos Mavrogiannopoulos <nmav@redhat.com>2016-10-13 16:42:29 +0200
commit4e43cbcf2b9e245973e12d7d17294e67d0d6834a (patch)
tree019e93b62b443cc0f178c6b43712dd40f5c5240a /src/pkcs11.c
parent85dcbfa786ac5a3f857640e59b9b38202b8a5f09 (diff)
downloadgnutls-4e43cbcf2b9e245973e12d7d17294e67d0d6834a.tar.gz
p11tool: improved messages on token initialization
Diffstat (limited to 'src/pkcs11.c')
-rw-r--r--src/pkcs11.c22
1 files changed, 15 insertions, 7 deletions
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__,