[sslproc] Allow absense of private key file

Backends can then assume that the private key is in the certificate file
This commit is contained in:
Aaron Jones 2016-05-05 03:25:59 +00:00
parent f831e92603
commit 4d83a4d92d
No known key found for this signature in database
GPG key ID: 6E854C0FAAD4CEA4

View file

@ -722,13 +722,22 @@ ssl_cmd_write_queue(ssl_ctl_t * ctl, rb_fde_t ** F, int count, const void *buf,
static void static void
send_new_ssl_certs_one(ssl_ctl_t * ctl) send_new_ssl_certs_one(ssl_ctl_t * ctl)
{ {
size_t len; size_t len = 5;
if(ServerInfo.ssl_cert)
len += strlen(ServerInfo.ssl_cert);
else
return;
if(ServerInfo.ssl_private_key)
len += strlen(ServerInfo.ssl_private_key);
len = strlen(ServerInfo.ssl_cert) + strlen(ServerInfo.ssl_private_key) + 5;
if(ServerInfo.ssl_dh_params) if(ServerInfo.ssl_dh_params)
len += strlen(ServerInfo.ssl_dh_params); len += strlen(ServerInfo.ssl_dh_params);
if(ServerInfo.ssl_cipher_list) if(ServerInfo.ssl_cipher_list)
len += strlen(ServerInfo.ssl_cipher_list); len += strlen(ServerInfo.ssl_cipher_list);
if(len > sizeof(tmpbuf)) if(len > sizeof(tmpbuf))
{ {
sendto_realops_snomask(SNO_GENERAL, L_ALL, sendto_realops_snomask(SNO_GENERAL, L_ALL,
@ -739,12 +748,15 @@ send_new_ssl_certs_one(ssl_ctl_t * ctl)
len, sizeof(tmpbuf)); len, sizeof(tmpbuf));
return; return;
} }
len = snprintf(tmpbuf, sizeof(tmpbuf), "K%c%s%c%s%c%s%c%s%c", nul,
ServerInfo.ssl_cert, nul, int ret = snprintf(tmpbuf, sizeof(tmpbuf), "K%c%s%c%s%c%s%c%s%c", nul,
ServerInfo.ssl_private_key, nul, ServerInfo.ssl_cert, nul,
ServerInfo.ssl_dh_params != NULL ? ServerInfo.ssl_dh_params : "", nul, ServerInfo.ssl_private_key != NULL ? ServerInfo.ssl_private_key : "", nul,
ServerInfo.ssl_cipher_list != NULL ? ServerInfo.ssl_cipher_list : "", nul); ServerInfo.ssl_dh_params != NULL ? ServerInfo.ssl_dh_params : "", nul,
ssl_cmd_write_queue(ctl, NULL, 0, tmpbuf, len); ServerInfo.ssl_cipher_list != NULL ? ServerInfo.ssl_cipher_list : "", nul);
if(ret > 5)
ssl_cmd_write_queue(ctl, NULL, 0, tmpbuf, (size_t) ret);
} }
static void static void