diff options
author | Daiki Ueno <ueno@gnu.org> | 2020-08-14 08:48:34 +0000 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2020-08-14 08:48:34 +0000 |
commit | 7f181164e0fa061084b8924bb22c24020c1dea88 (patch) | |
tree | ea82856b9fda1d92f9baf0c360f31eb3e37667b7 | |
parent | 92b78b7830be5d12cfa24673d81300ba6e851ce0 (diff) | |
parent | 5fca5aaf137eeaa9058847f5390fdc3d89926ade (diff) | |
download | gnutls-7f181164e0fa061084b8924bb22c24020c1dea88.tar.gz |
Merge branch 'tmp-fix-cert-pass' into 'master'
Fix two issues about certtool and passwords
Closes #933 and #888
See merge request gnutls/gnutls!1268
-rw-r--r-- | src/certtool.c | 3 | ||||
-rw-r--r-- | src/common.c | 9 |
2 files changed, 11 insertions, 1 deletions
diff --git a/src/certtool.c b/src/certtool.c index 6bdfe376b1..6c1f04656b 100644 --- a/src/certtool.c +++ b/src/certtool.c @@ -3027,7 +3027,8 @@ void generate_pkcs12(common_info_st * cinfo) app_exit(1); } - result = gnutls_pkcs12_bag_encrypt(bag, pass, flags); + if (!(flags & GNUTLS_PKCS_PLAIN) || cinfo->empty_password) + result = gnutls_pkcs12_bag_encrypt(bag, pass, flags); if (result < 0) { fprintf(stderr, "bag_encrypt: %s\n", gnutls_strerror(result)); 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); |