]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
When the --provider option is given, initialize PKCS #11 prior to calling gnutls_glob...
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 5 Apr 2014 08:41:32 +0000 (10:41 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sat, 5 Apr 2014 08:41:34 +0000 (10:41 +0200)
This ensures that the PKCS #11 subsystem will not be initialized twice.

src/p11tool.c

index cf9ccb7d5840e584aa82d9cb5ace567de34721bd..a1d492f126f062c4483956d9aa62067c3b54dddf 100644 (file)
@@ -93,11 +93,6 @@ static void cmd_parser(int argc, char **argv)
        if (debug > 1)
                printf("Setting log level to %d\n", debug);
 
-       if ((ret = gnutls_global_init()) < 0) {
-               fprintf(stderr, "global_init: %s", gnutls_strerror(ret));
-               exit(1);
-       }
-
        if (HAVE_OPT(PROVIDER)) {
                ret = gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_MANUAL, NULL);
                if (ret < 0)
@@ -113,11 +108,11 @@ static void cmd_parser(int argc, char **argv)
                                exit(1);
                        }
                }
-       } else {
-               ret = gnutls_pkcs11_init(GNUTLS_PKCS11_FLAG_AUTO, NULL);
-               if (ret < 0)
-                       fprintf(stderr, "pkcs11_init: %s",
-                               gnutls_strerror(ret));
+       }
+
+       if ((ret = gnutls_global_init()) < 0) {
+               fprintf(stderr, "global_init: %s", gnutls_strerror(ret));
+               exit(1);
        }
 
        if (HAVE_OPT(OUTFILE)) {