summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Baryshkov <dbaryshkov@gmail.com>2020-05-27 23:42:01 +0300
committerDmitry Baryshkov <dbaryshkov@gmail.com>2020-05-28 05:05:02 +0300
commit3feac2af3c11996fb8371d7d035692fbc8c74bd2 (patch)
tree960608bbccafd5ac77d445e0d7646363624421bf
parent12080aa26a8d963acdfa3aa1b8b444f5f58af6bd (diff)
downloadgnutls-3feac2af3c11996fb8371d7d035692fbc8c74bd2.tar.gz
certtool: do not ask for private key password if it was provided
Make pin_callback() use cinfo->password if it is set (via command line or from template). Fixes #933 Signed-off-by: Dmitry Baryshkov <dbaryshkov@gmail.com>
-rw-r--r--src/common.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
index 753481741b..a7e784e666 100644
--- a/src/common.c
+++ b/src/common.c
@@ -1138,6 +1138,15 @@ pin_callback(void *user, int attempt, const char *token_url,
getenv_copy(password, sizeof(password), "GNUTLS_PIN");
}
+ if (password[0] == 0 && info != NULL && info->password != NULL && info->ask_pass == 0) {
+ if (strlen(info->password) < sizeof(password)) {
+ strcpy(password, info->password);
+ } else {
+ memcpy(password, info->password, sizeof(password) - 1);
+ password[sizeof(password) - 1] = '\0';
+ }
+ }
+
if (password[0] == 0 && (info == NULL || info->batch == 0 || info->ask_pass != 0)) {
if (token_label && token_label[0] != 0) {
fprintf(stderr, "Token '%s' with URL '%s' ", token_label, token_url);