From: Matthieu Patou Date: Wed, 27 Oct 2010 18:59:25 +0000 (+0400) Subject: tls: Inform the user if the cert/ca/private key can't be saved X-Git-Tag: samba-4.0.0alpha14~1609 X-Git-Url: http://git.samba.org/samba.git/?p=samba.git;a=commitdiff_plain;h=f8d49958b2a5c55e837ebe903dd5207a92d19d63 tls: Inform the user if the cert/ca/private key can't be saved Most of the time this problem is due to a missing /tls dir. Should close bug 7640. Autobuild-User: Matthieu Patou Autobuild-Date: Wed Oct 27 20:08:54 UTC 2010 on sn-devel-104 --- diff --git a/source4/lib/tls/tlscert.c b/source4/lib/tls/tlscert.c index 62e7a72240d..bef634803a6 100644 --- a/source4/lib/tls/tlscert.c +++ b/source4/lib/tls/tlscert.c @@ -138,15 +138,24 @@ void tls_cert_generate(TALLOC_CTX *mem_ctx, bufsize = sizeof(buf); TLSCHECK(gnutls_x509_crt_export(crt, GNUTLS_X509_FMT_PEM, buf, &bufsize)); - file_save(certfile, buf, bufsize); + if (!file_save(certfile, buf, bufsize)) { + DEBUG(0,("Unable to save certificate in %s parent dir exists ?\n", certfile)); + goto failed; + } bufsize = sizeof(buf); TLSCHECK(gnutls_x509_crt_export(cacrt, GNUTLS_X509_FMT_PEM, buf, &bufsize)); - file_save(cafile, buf, bufsize); + if (!file_save(cafile, buf, bufsize)) { + DEBUG(0,("Unable to save ca cert in %s parent dir exists ?\n", cafile)); + goto failed; + } bufsize = sizeof(buf); TLSCHECK(gnutls_x509_privkey_export(key, GNUTLS_X509_FMT_PEM, buf, &bufsize)); - file_save(keyfile, buf, bufsize); + if (!file_save(keyfile, buf, bufsize)) { + DEBUG(0,("Unable to save privatekey in %s parent dir exists ?\n", keyfile)); + goto failed; + } gnutls_x509_privkey_deinit(key); gnutls_x509_privkey_deinit(cakey);