char version[256];
};
-static void send_new_ssl_certs_one(ssl_ctl_t * ctl, const char *ssl_cert,
- const char *ssl_private_key, const char *ssl_dh_params,
- const char *ssl_cipher_list);
-static void send_init_prng(ssl_ctl_t * ctl, prng_seed_t seedtype, const char *path);
-static void send_certfp_method(ssl_ctl_t *ctl, int method);
+static void ssld_update_config_one(ssl_ctl_t *ctl);
+static void send_new_ssl_certs_one(ssl_ctl_t * ctl);
+static void send_certfp_method(ssl_ctl_t *ctl);
static rb_dlink_list ssl_daemons;
}
}
- start_ssldaemon(ServerInfo.ssld_count, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list);
+ start_ssldaemon(ServerInfo.ssld_count);
}
static void
ssld_count--;
ilog(L_MAIN, "ssld helper died - attempting to restart");
sendto_realops_snomask(SNO_GENERAL, L_ALL, "ssld helper died - attempting to restart");
- start_ssldaemon(1, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list);
+ start_ssldaemon(1);
}
}
int start = ServerInfo.ssld_count - get_ssld_count();
ilog(L_MAIN, "Attempting to restart ssld processes");
sendto_realops_snomask(SNO_GENERAL, L_ALL, "Attempt to restart ssld processes");
- start_ssldaemon(start, ServerInfo.ssl_cert, ServerInfo.ssl_private_key, ServerInfo.ssl_dh_params, ServerInfo.ssl_cipher_list);
+ start_ssldaemon(start);
}
}
int
-start_ssldaemon(int count, const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params, const char *ssl_cipher_list)
+start_ssldaemon(int count)
{
rb_fde_t *F1, *F2;
rb_fde_t *P1, *P2;
rb_close(P1);
ctl = allocate_ssl_daemon(F1, P2, pid);
if(ircd_ssl_ok)
- {
- send_init_prng(ctl, RB_PRNG_DEFAULT, NULL);
- send_certfp_method(ctl, ConfigFileEntry.certfp_method);
-
- if(ssl_cert != NULL && ssl_private_key != NULL)
- send_new_ssl_certs_one(ctl, ssl_cert, ssl_private_key,
- ssl_dh_params != NULL ? ssl_dh_params : "",
- ssl_cipher_list != NULL ? ssl_cipher_list : "");
- }
+ ssld_update_config_one(ctl);
ssl_read_ctl(ctl->F, ctl);
ssl_do_pipe(P2, ctl);
zips->out_ratio = 0;
}
+static void
+ssl_process_open_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
+{
+ struct Client *client_p;
+ uint32_t fd;
+
+ if(ctl_buf->buflen < 5)
+ return; /* bogus message..drop it.. XXX should warn here */
+
+ fd = buf_to_uint32(&ctl_buf->buf[1]);
+ client_p = find_cli_connid_hash(fd);
+ if(client_p == NULL || client_p->localClient == NULL)
+ return;
+
+ if(client_p->localClient->ssl_callback)
+ {
+ SSL_OPEN_CB *hdl = client_p->localClient->ssl_callback;
+
+ client_p->localClient->ssl_callback = NULL;
+
+ hdl(client_p, RB_OK);
+ }
+}
+
static void
ssl_process_dead_fd(ssl_ctl_t * ctl, ssl_ctl_buf_t * ctl_buf)
{
fd = buf_to_uint32(&ctl_buf->buf[1]);
rb_strlcpy(reason, &ctl_buf->buf[5], sizeof(reason));
client_p = find_cli_connid_hash(fd);
- if(client_p == NULL)
+ if(client_p == NULL || client_p->localClient == NULL)
return;
+
+ if(IsAnyServer(client_p))
+ {
+ sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) && !IsServer(client_p) ? L_NETWIDE : L_ALL, "ssld error for %s: %s", client_p->name, reason);
+ ilog(L_SERVER, "ssld error for %s: %s", log_client_name(client_p, SHOW_IP), reason);
+ }
+
+ /* if there is still a pending callback, call it now */
+ if(client_p->localClient->ssl_callback)
+ {
+ SSL_OPEN_CB *hdl = client_p->localClient->ssl_callback;
+
+ client_p->localClient->ssl_callback = NULL;
+
+ if (hdl(client_p, RB_ERROR_SSL))
+ {
+ /* the callback has exited the client */
+ return;
+ }
+ }
+
if(IsAnyServer(client_p) || IsRegistered(client_p))
{
/* read any last moment ERROR, QUIT or the like -- jilles */
if (IsAnyDead(client_p))
return;
}
- if(IsAnyServer(client_p))
- {
- sendto_realops_snomask(SNO_GENERAL, is_remote_connect(client_p) && !IsServer(client_p) ? L_NETWIDE : L_ALL, "ssld error for %s: %s", client_p->name, reason);
- ilog(L_SERVER, "ssld error for %s: %s", log_client_name(client_p, SHOW_IP), reason);
- }
exit_client(client_p, client_p, &me, reason);
}
{
struct Client *client_p;
uint32_t fd;
+ uint32_t certfp_method;
uint32_t len;
uint8_t *certfp;
char *certfp_string;
+ const char *method_string;
+ int method_len;
- if(ctl_buf->buflen > 5 + RB_SSL_CERTFP_LEN)
+ if(ctl_buf->buflen > 13 + RB_SSL_CERTFP_LEN)
return; /* bogus message..drop it.. XXX should warn here */
fd = buf_to_uint32(&ctl_buf->buf[1]);
- len = buf_to_uint32(&ctl_buf->buf[5]);
- certfp = (uint8_t *)&ctl_buf->buf[9];
+ certfp_method = buf_to_uint32(&ctl_buf->buf[5]);
+ len = buf_to_uint32(&ctl_buf->buf[9]);
+ certfp = (uint8_t *)&ctl_buf->buf[13];
client_p = find_cli_connid_hash(fd);
if(client_p == NULL)
return;
+
+ switch (certfp_method) {
+ case RB_SSL_CERTFP_METH_CERT_SHA1:
+ case RB_SSL_CERTFP_METH_CERT_SHA256:
+ case RB_SSL_CERTFP_METH_CERT_SHA512:
+ method_string = "";
+ break;
+
+ /* These names are copied from RFC 7218 */
+ case RB_SSL_CERTFP_METH_SPKI_SHA256:
+ method_string = "SPKI:SHA2-256:";
+ break;
+ case RB_SSL_CERTFP_METH_SPKI_SHA512:
+ method_string = "SPKI:SHA2-512:";
+ break;
+ default:
+ return;
+ }
+ method_len = strlen(method_string);
+
rb_free(client_p->certfp);
- certfp_string = rb_malloc(len * 2 + 1);
+ certfp_string = rb_malloc(method_len + len * 2 + 1);
+ strcpy(certfp_string, method_string);
for(uint32_t i = 0; i < len; i++)
- snprintf(certfp_string + 2 * i, 3, "%02x",
+ snprintf(certfp_string + method_len + 2 * i, 3, "%02x",
certfp[i]);
client_p->certfp = certfp_string;
}
case 'N':
ircd_ssl_ok = false; /* ssld says it can't do ssl/tls */
break;
+ case 'O':
+ ssl_process_open_fd(ctl, ctl_buf);
+ break;
case 'D':
ssl_process_dead_fd(ctl, ctl_buf);
break;
static void
-send_new_ssl_certs_one(ssl_ctl_t * ctl, const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params, const char *ssl_cipher_list)
+send_new_ssl_certs_one(ssl_ctl_t * ctl)
{
size_t len;
- len = strlen(ssl_cert) + strlen(ssl_private_key) + strlen(ssl_dh_params) + 5;
+ len = strlen(ServerInfo.ssl_cert) + strlen(ServerInfo.ssl_private_key) + 5;
+ if(ServerInfo.ssl_dh_params)
+ len += strlen(ServerInfo.ssl_dh_params);
+ if(ServerInfo.ssl_cipher_list)
+ len += strlen(ServerInfo.ssl_cipher_list);
if(len > sizeof(tmpbuf))
{
sendto_realops_snomask(SNO_GENERAL, L_ALL,
len, sizeof(tmpbuf));
return;
}
- len = snprintf(tmpbuf, sizeof(tmpbuf), "K%c%s%c%s%c%s%c%s%c", nul, ssl_cert, nul,
- ssl_private_key, nul, ssl_dh_params, nul,
- ssl_cipher_list != NULL ? ssl_cipher_list : "", nul);
+ len = snprintf(tmpbuf, sizeof(tmpbuf), "K%c%s%c%s%c%s%c%s%c", nul,
+ ServerInfo.ssl_cert, nul,
+ ServerInfo.ssl_private_key, nul,
+ ServerInfo.ssl_dh_params != NULL ? ServerInfo.ssl_dh_params : "", nul,
+ ServerInfo.ssl_cipher_list != NULL ? ServerInfo.ssl_cipher_list : "", nul);
ssl_cmd_write_queue(ctl, NULL, 0, tmpbuf, len);
}
static void
-send_init_prng(ssl_ctl_t * ctl, prng_seed_t seedtype, const char *path)
+send_certfp_method(ssl_ctl_t *ctl)
{
- size_t len;
- const char *s;
- uint8_t seed = (uint8_t) seedtype;
-
- if(path == NULL)
- s = "";
- else
- s = path;
-
- len = strlen(s) + 3;
- if(len > sizeof(tmpbuf))
- {
- sendto_realops_snomask(SNO_GENERAL, L_ALL,
- "Parameters for send_init_prng too long (%zd > %zd) to pass to ssld, not sending...",
- len, sizeof(tmpbuf));
- ilog(L_MAIN,
- "Parameters for send_init_prng too long (%zd > %zd) to pass to ssld, not sending...",
- len, sizeof(tmpbuf));
- return;
+ char buf[5];
- }
- len = snprintf(tmpbuf, sizeof(tmpbuf), "I%c%s%c", seed, s, nul);
- ssl_cmd_write_queue(ctl, NULL, 0, tmpbuf, len);
+ buf[0] = 'F';
+ uint32_to_buf(&buf[1], ConfigFileEntry.certfp_method);
+ ssl_cmd_write_queue(ctl, NULL, 0, buf, sizeof(buf));
}
static void
-send_certfp_method(ssl_ctl_t *ctl, int method)
+ssld_update_config_one(ssl_ctl_t *ctl)
{
- char buf[5];
-
- buf[0] = 'F';
- uint32_to_buf(&buf[1], method);
- ssl_cmd_write_queue(ctl, NULL, 0, buf, sizeof(buf));
+ send_certfp_method(ctl);
+ send_new_ssl_certs_one(ctl);
}
void
-send_new_ssl_certs(const char *ssl_cert, const char *ssl_private_key, const char *ssl_dh_params, const char *ssl_cipher_list)
+ssld_update_config(void)
{
rb_dlink_node *ptr;
- if(ssl_cert == NULL || ssl_private_key == NULL || ssl_dh_params == NULL)
- {
- ircd_ssl_ok = false;
- return;
- }
+
RB_DLINK_FOREACH(ptr, ssl_daemons.head)
{
ssl_ctl_t *ctl = ptr->data;
- send_new_ssl_certs_one(ctl, ssl_cert, ssl_private_key, ssl_dh_params, ssl_cipher_list);
+ ssld_update_config_one(ctl);
}
}
-
ssl_ctl_t *
start_ssld_accept(rb_fde_t * sslF, rb_fde_t * plainF, uint32_t id)
{