summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-06-06 18:43:12 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-06-06 18:49:53 +0200
commit0adb22f395bd9a270471685d116e66259fdbebf3 (patch)
treef1d5a07f31846279ae61d78f8155374eccefabbe
parent834649e6c635e48e37f0054d7815858c544902ee (diff)
downloadgnutls-0adb22f395bd9a270471685d116e66259fdbebf3.tar.gz
keylogfile: only consider the SSLKEYLOGFILE variable
In addition do not check the environment in the constructor but instead use static variables to save the key file name. The GNUTLS_KEYLOGFILE environment variable is no longer used since there is no reason to have a separate one.
-rw-r--r--lib/gnutls_global.c5
-rw-r--r--lib/gnutls_global.h2
-rw-r--r--lib/gnutls_kx.c11
3 files changed, 9 insertions, 9 deletions
diff --git a/lib/gnutls_global.c b/lib/gnutls_global.c
index e155798dc0..a54d42c7b7 100644
--- a/lib/gnutls_global.c
+++ b/lib/gnutls_global.c
@@ -70,7 +70,6 @@ extern const ASN1_ARRAY_TYPE gnutls_asn1_tab[];
extern const ASN1_ARRAY_TYPE pkix_asn1_tab[];
void *_gnutls_file_mutex;
void *_gnutls_pkcs11_mutex;
-const char *_gnutls_keylogfile = NULL;
ASN1_TYPE _gnutls_pkix1_asn = ASN1_TYPE_EMPTY;
ASN1_TYPE _gnutls_gnutls_asn = ASN1_TYPE_EMPTY;
@@ -241,10 +240,6 @@ int gnutls_global_init(void)
_gnutls_switch_lib_state(LIB_STATE_INIT);
- _gnutls_keylogfile = secure_getenv("GNUTLS_KEYLOGFILE");
- if (_gnutls_keylogfile == NULL)
- _gnutls_keylogfile = secure_getenv("SSLKEYLOGFILE");
-
e = secure_getenv("GNUTLS_DEBUG_LEVEL");
if (e != NULL) {
level = atoi(e);
diff --git a/lib/gnutls_global.h b/lib/gnutls_global.h
index e7b3613c93..e1a8f2e25c 100644
--- a/lib/gnutls_global.h
+++ b/lib/gnutls_global.h
@@ -38,8 +38,6 @@ extern ASN1_TYPE _gnutls_gnutls_asn;
#define _gnutls_get_gnutls_asn() ((ASN1_TYPE) _gnutls_gnutls_asn)
#define _gnutls_get_pkix() ((ASN1_TYPE) _gnutls_pkix1_asn)
-extern const char *_gnutls_keylogfile;
-
extern gnutls_log_func _gnutls_log_func;
extern gnutls_audit_log_func _gnutls_audit_log_func;
extern int _gnutls_log_level;
diff --git a/lib/gnutls_kx.c b/lib/gnutls_kx.c
index 6fe4ef6d32..e46fd95df4 100644
--- a/lib/gnutls_kx.c
+++ b/lib/gnutls_kx.c
@@ -100,11 +100,18 @@ static void write_nss_key_log(gnutls_session_t session, const gnutls_datum_t *pr
char buf[512];
char buf2[512];
FILE *fp;
+ static const char *keylogfile = NULL;
+ static unsigned checked_env = 0;
- if (_gnutls_keylogfile == NULL)
+ if (!checked_env) {
+ checked_env = 1;
+ keylogfile = secure_getenv("SSLKEYLOGFILE");
+ }
+
+ if (keylogfile == NULL)
return;
- fp = fopen(_gnutls_keylogfile, "a");
+ fp = fopen(keylogfile, "a");
if (fp == NULL)
return;