unsigned int nr_certs;
err = load_datum(vpninfo, &datum, vpninfo->cafile);
- if (err < 0)
+ if (err < 0) {
+ gnutls_certificate_free_credentials(vpninfo->https_cred);
+ vpninfo->https_cred = NULL;
return err;
+ }
/* For GnuTLS 3.x We should use gnutls_x509_crt_list_import2() */
nr_certs = count_x509_certificates(&datum);
vpn_progress(vpninfo, PRG_ERR,
_("Failed to allocate memory for cafile certs\n"));
gnutls_free(datum.data);
+ gnutls_certificate_free_credentials(vpninfo->https_cred);
+ vpninfo->https_cred = NULL;
close(ssl_sock);
return -ENOMEM;
}
vpn_progress(vpninfo, PRG_ERR,
_("Failed to read certs from cafile: %s\n"),
gnutls_strerror(err));
+ gnutls_certificate_free_credentials(vpninfo->https_cred);
+ vpninfo->https_cred = NULL;
close(ssl_sock);
return -EINVAL;
}
vpn_progress(vpninfo, PRG_ERR,
_("Failed to open CA file '%s': %s\n"),
vpninfo->cafile, gnutls_strerror(err));
+ gnutls_certificate_free_credentials(vpninfo->https_cred);
+ vpninfo->https_cred = NULL;
close(ssl_sock);
return -EINVAL;
}
if (err) {
vpn_progress(vpninfo, PRG_ERR,
_("Loading certificate failed. Aborting.\n"));
+ gnutls_certificate_free_credentials(vpninfo->https_cred);
+ vpninfo->https_cred = NULL;
close(ssl_sock);
return err;
}