]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Allow getting the PIN from the GNUTLS_PKCS11_PIN environment variable.
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 10 Nov 2013 07:23:37 +0000 (08:23 +0100)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Sun, 10 Nov 2013 07:23:37 +0000 (08:23 +0100)
src/common.c
src/p11tool-args.def

index 75728985d7911018347f6ccf5066515480210362..d5a0c33a768ab9b9a23c8ba940370468237d0dd5 100644 (file)
@@ -961,7 +961,7 @@ pin_callback(void *user, int attempt, const char *token_url,
             const char *token_label, unsigned int flags, char *pin,
             size_t pin_max)
 {
-       const char *password;
+       const char *password = NULL;
        const char *desc;
        int cache = MAX_CACHE_TRIES;
        unsigned len;
@@ -1007,8 +1007,18 @@ pin_callback(void *user, int attempt, const char *token_url,
 
        printf("Token '%s' with URL '%s' ", token_label, token_url);
        printf("requires %s PIN\n", desc);
+       
+       password = getenv("GNUTLS_PKCS11_PIN");
+
+       if (password == NULL)
+               password = getpass("Enter PIN: ");
+       else {
+               if (flags & GNUTLS_PIN_WRONG) {
+                       fprintf(stderr, "Cannot continue with a wrong password in the environment.\n");
+                       exit(1);
+               }
+       }
 
-       password = getpass("Enter PIN: ");
        if (password == NULL || password[0] == 0) {
                fprintf(stderr, "No password given\n");
                exit(1);
index 94414897259f501e3499d730fcfec15ea3d6e54d..f8068ba44acc227bc3c8ad4555968f8d14ecc035 100644 (file)
@@ -7,6 +7,10 @@ and security modules.
 
 To use PKCS #11 tokens with gnutls the configuration file 
 /etc/gnutls/pkcs11.conf has to exist and contain a number of lines of the form 'load=/usr/lib/opensc-pkcs11.so'.
+Alternatively the p11-kit configuration files have to be setup.
+
+To provide the PIN for all the operations below use the environment variable
+GNUTLS_PKCS11_PIN.
 ";
 
 short-usage   = "p11tool [options] [url]\np11tool --help for usage instructions.\n";