]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
TLS client: fix certificate loading from file
authorPetr Špaček <petr.spacek@nic.cz>
Thu, 18 Jan 2018 13:11:16 +0000 (14:11 +0100)
committerPetr Špaček <petr.spacek@nic.cz>
Thu, 18 Jan 2018 15:30:07 +0000 (16:30 +0100)
gnutls_certificate_set_x509_trust_file could theoretically return 0
to indicate nothing was read, so we need to check for this as well.

daemon/tls.c

index 7c92be92a466e518d40424ece57ae38f50b367f1..cf1080720928181c6c75db46186f5ed91bad0234 100644 (file)
@@ -620,7 +620,7 @@ int tls_client_params_set(map_t *tls_client_paramlist,
                        } else {
                                int res = gnutls_certificate_set_x509_trust_file(entry->credentials, value,
                                                                                 GNUTLS_X509_FMT_PEM);
-                               if (res < 0) {
+                               if (res <= 0) {
                                        kr_log_error("[tls_client] failed to import certificate file '%s' (%s)\n",
                                                     value, gnutls_strerror_name(res));
                                        /* value will be freed at cleanup */