Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ssl socket activation #2323

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core/setup_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ void uwsgi_setup_systemd() {
if (listen_fds) {
int systemd_fds = atoi(listen_fds);
if (systemd_fds > 0) {
uwsgi_log("- SystemD socket activation detected -\n");
uwsgi_log("- systemd socket activation detected -\n");
for (i = 3; i < 3 + systemd_fds; i++) {
uwsgi_sock = uwsgi_new_socket(NULL);
uwsgi_add_socket_from_fd(uwsgi_sock, i);
Expand Down
32 changes: 32 additions & 0 deletions core/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,10 +1155,26 @@ void uwsgi_add_socket_from_fd(struct uwsgi_socket *uwsgi_sock, int fd) {
uwsgi_sock->family = AF_INET;
uwsgi_sock->bound = 1;
uwsgi_sock->name = uwsgi_concat2(computed_addr, "");
uwsgi_sock->name_len = strlen(uwsgi_sock->name);
if (uwsgi.zerg) {
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 @@ -1222,10 +1238,26 @@ void uwsgi_add_socket_from_fd(struct uwsgi_socket *uwsgi_sock, int fd) {
uwsgi_sock->family = AF_INET6;
uwsgi_sock->bound = 1;
uwsgi_sock->name = uwsgi_concat2(computed_addr, "");
uwsgi_sock->name_len = strlen(uwsgi_sock->name);
if (uwsgi.zerg) {
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