Invert the meaning of the return.
if (addr->peercert)
{
ptr = big_buffer;
- if (!tls_export_cert(ptr, big_buffer_size-2, addr->peercert))
+ if (tls_export_cert(ptr, big_buffer_size-2, addr->peercert))
while(*ptr++);
else
*ptr++ = 0;
if (addr->ourcert)
{
ptr = big_buffer;
- if (!tls_export_cert(ptr, big_buffer_size-2, addr->ourcert))
+ if (tls_export_cert(ptr, big_buffer_size-2, addr->ourcert))
while(*ptr++);
else
*ptr++ = 0;
extern void tls_close(void *, int);
extern BOOL tls_could_read(void);
extern void tls_daemon_init(void);
-extern int tls_export_cert(uschar *, size_t, void *);
+extern BOOL tls_export_cert(uschar *, size_t, void *);
extern int tls_feof(void);
extern int tls_ferror(void);
extern void tls_free_cert(void **);
if (tls_in.cipher) spool_var_write(fp, US"tls_cipher", tls_in.cipher);
if (tls_in.peercert)
{
- (void) tls_export_cert(big_buffer, big_buffer_size, tls_in.peercert);
- fprintf(fp, "--tls_peercert %s\n", CS big_buffer);
+ if (tls_export_cert(big_buffer, big_buffer_size, tls_in.peercert))
+ fprintf(fp, "--tls_peercert %s\n", CS big_buffer);
}
if (tls_in.peerdn) spool_var_write(fp, US"tls_peerdn", string_printing(tls_in.peerdn));
if (tls_in.sni) spool_var_write(fp, US"tls_sni", string_printing(tls_in.sni));
if (tls_in.ourcert)
{
- (void) tls_export_cert(big_buffer, big_buffer_size, tls_in.ourcert);
- fprintf(fp, "-tls_ourcert %s\n", CS big_buffer);
+ if (tls_export_cert(big_buffer, big_buffer_size, tls_in.ourcert))
+ fprintf(fp, "-tls_ourcert %s\n", CS big_buffer);
}
if (tls_in.ocsp) fprintf(fp, "-tls_ocsp %d\n", tls_in.ocsp);
# ifdef EXPERIMENTAL_TLS_RESUME
/*****************************************************
* Export/import a certificate, binary/printable
*****************************************************/
-int
+BOOL
tls_export_cert(uschar * buf, size_t buflen, void * cert)
{
size_t sz = buflen;
rmark reset_point = store_mark();
-int fail;
+BOOL fail;
const uschar * cp;
if ((fail = gnutls_x509_crt_export((gnutls_x509_crt_t)cert,
{
log_write(0, LOG_MAIN, "TLS error in certificate export: %s",
gnutls_strerror(fail));
- return 1;
+ return 0;
}
if ((cp = string_printing(buf)) != buf)
{
fail = 1;
}
store_reset(reset_point);
-return fail;
+return !fail;
}
int
/*****************************************************
* Export/import a certificate, binary/printable
*****************************************************/
-int
+BOOL
tls_export_cert(uschar * buf, size_t buflen, void * cert)
{
BIO * bp = BIO_new(BIO_s_mem());
-int fail;
+BOOL fail;
if ((fail = PEM_write_bio_X509(bp, (X509 *)cert) ? 0 : 1))
log_write(0, LOG_MAIN, "TLS error in certificate export: %s",
}
BIO_free(bp);
-return fail;
+return !fail;
}
int