Skip to content

Commit

Permalink
Apply SSL configuration to sockets from systemd or upstart
Browse files Browse the repository at this point in the history
When adding a socket from an fd search the list of configured sockets
for a socket with the same name. If such socket is found and it has SSL
context configured with https-socket, move the context to the received
socket because the configured one won't be bound anyway.
  • Loading branch information
steelman committed Jun 7, 2021
1 parent c0c5298 commit 12b3997
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions core/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,21 @@ void uwsgi_add_socket_from_fd(struct uwsgi_socket *uwsgi_sock, int fd) {
uwsgi_log("uwsgi zerg socket %d attached to INET address %s fd %d\n", uwsgi_get_socket_num(uwsgi_sock), computed_addr, uwsgi_sock->fd);
}
else {
struct uwsgi_socket *us = uwsgi.sockets;
while (us) {
/*
* Apply SSL configuration for https-socket
* under the same name to the the socket received form
* systemd or upstart.
*/
if (!strcmp(us->name, computed_addr)) {
uwsgi_sock->proto_name = uwsgi_concat2(us->proto_name, "");
uwsgi_sock->ssl_ctx = us->ssl_ctx;
us->ssl_ctx = NULL;
break;
}
us = us->next;
}
uwsgi_log("uwsgi socket %d attached to INET address %s fd %d\n", uwsgi_get_socket_num(uwsgi_sock), computed_addr, uwsgi_sock->fd);
}
free(computed_addr);
Expand Down Expand Up @@ -1228,6 +1243,21 @@ void uwsgi_add_socket_from_fd(struct uwsgi_socket *uwsgi_sock, int fd) {
uwsgi_log("uwsgi zerg socket %d attached to INET6 address %s fd %d\n", uwsgi_get_socket_num(uwsgi_sock), computed_addr, uwsgi_sock->fd);
}
else {
struct uwsgi_socket *us = uwsgi.sockets;
while (us) {
/*
* Apply SSL configuration for https-socket
* under the same name to the the socket received form
* systemd or upstart.
*/
if (!strcmp(us->name, computed_addr)) {
uwsgi_sock->proto_name = uwsgi_concat2(us->proto_name, "");
uwsgi_sock->ssl_ctx = us->ssl_ctx;
us->ssl_ctx = NULL;
break;
}
us = us->next;
}
uwsgi_log("uwsgi socket %d attached to INET6 address %s fd %d\n", uwsgi_get_socket_num(uwsgi_sock), computed_addr, uwsgi_sock->fd);
}
free(computed_addr);
Expand Down

0 comments on commit 12b3997

Please sign in to comment.