summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/nsd_gtls.c19
-rw-r--r--runtime/rsyslog.h5
2 files changed, 21 insertions, 3 deletions
diff --git a/runtime/nsd_gtls.c b/runtime/nsd_gtls.c
index 6ef4feba..1110c7a4 100644
--- a/runtime/nsd_gtls.c
+++ b/runtime/nsd_gtls.c
@@ -2,7 +2,7 @@
*
* An implementation of the nsd interface for GnuTLS.
*
- * Copyright (C) 2007, 2008 Rainer Gerhards and Adiscon GmbH.
+ * Copyright (C) 2007-2013 Rainer Gerhards and Adiscon GmbH.
*
* This file is part of the rsyslog runtime library.
*
@@ -547,10 +547,20 @@ gtlsAddOurCert(void)
keyFile = glbl.GetDfltNetstrmDrvrKeyFile();
dbgprintf("GTLS certificate file: '%s'\n", certFile);
dbgprintf("GTLS key file: '%s'\n", keyFile);
+ if(certFile == NULL) {
+ errmsg.LogError(0, RS_RET_CERT_MISSING, "error: certificate file is not set, cannot "
+ "continue");
+ ABORT_FINALIZE(RS_RET_CERT_MISSING);
+ }
+ if(keyFile == NULL) {
+ errmsg.LogError(0, RS_RET_CERTKEY_MISSING, "error: key file is not set, cannot "
+ "continue");
+ ABORT_FINALIZE(RS_RET_CERTKEY_MISSING);
+ }
CHKgnutls(gnutls_certificate_set_x509_key_file(xcred, (char*)certFile, (char*)keyFile, GNUTLS_X509_FMT_PEM));
finalize_it:
- if(iRet != RS_RET_OK) {
+ if(iRet != RS_RET_OK && iRet != RS_RET_CERT_MISSING && iRet != RS_RET_CERTKEY_MISSING) {
pGnuErr = gtlsStrerror(gnuRet);
errno = 0;
errmsg.LogError(0, iRet, "error adding our certificate. GnuTLS error %d, message: '%s', "
@@ -580,6 +590,11 @@ gtlsGlblInit(void)
/* sets the trusted cas file */
cafile = glbl.GetDfltNetstrmDrvrCAF();
+ if(cafile == NULL) {
+ errmsg.LogError(0, RS_RET_CA_CERT_MISSING, "error: ca certificate is not set, cannot "
+ "continue");
+ ABORT_FINALIZE(RS_RET_CA_CERT_MISSING);
+ }
dbgprintf("GTLS CA file: '%s'\n", cafile);
gnuRet = gnutls_certificate_set_x509_trust_file(xcred, (char*)cafile, GNUTLS_X509_FMT_PEM);
if(gnuRet < 0) {
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index e51f11bd..7cad3eae 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -3,7 +3,7 @@
*
* Begun 2005-09-15 RGerhards
*
- * Copyright (C) 2005-2008 by Rainer Gerhards and Adiscon GmbH
+ * Copyright (C) 2005-2013 by Rainer Gerhards and Adiscon GmbH
*
* This file is part of the rsyslog runtime library.
*
@@ -415,6 +415,9 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_CRY_INVLD_ALGO = -2326,/**< user specified invalid (unkonwn) crypto algorithm */
RS_RET_CRY_INVLD_MODE = -2327,/**< user specified invalid (unkonwn) crypto mode */
RS_RET_QUEUE_DISK_NO_FN = -2328,/**< disk queue configured, but filename not set */
+ RS_RET_CA_CERT_MISSING = -2329,/**< a CA cert is missing where one is required (e.g. TLS) */
+ RS_RET_CERT_MISSING = -2330,/**< a cert is missing where one is required (e.g. TLS) */
+ RS_RET_CERTKEY_MISSING = -2331,/**< a cert (private) key is missing where one is required (e.g. TLS) */
/* up to 2350 reserved for 7.4 */
RS_RET_QUEUE_CRY_DISK_ONLY = -2351,/**< crypto provider only supported for disk-associated queues */
RS_RET_NO_DATA = -2352,/**< file has no data; more a state than a real error */