Open mmguero opened 4 years ago
Just spitballing, perhaps the same value could be pulled from c->conn->sockaddr
or c->server->parsed_url->sockaddr
?
Looking at this a little bit closer, here's what I think would be really neat:
Right now the code in ngx_http_auth_ldap_ssl_handshake_handler
verifies the chain (long chain_verified = SSL_get_verify_result(conn->ssl->connection)
) and then verifies the hostname (addr_verified = X509_check_host(cert, hostname, 0, 0, 0)
) or IP address (X509_check_ip(cert, (const unsigned char*)conn->sockaddr->sa_data, len, 0)
).
It would be nice to have the ability to verify the chain without checking the host/ip. stunnel does this by allowing you to specify a checkHost
or checkIP
value. If unspecified, the chain is verified without the host/IP being checked.
Maybe ssl_check_cert
could have, instead of on
and off
, on
, off
, and chain
or something like that? That would allow checking against the CA without going to the host/ip check.
I'm working on something in my fork of this plugin to handle the case of the last comment:
compare kvspb/nginx-auth-ldap/master ... mmguero-dev/nginx-auth-ldap/master
This does't fix the bug, but it would allow a partial verification of the file while maintaining backwards compatibility. I'm going to do some more testing and do a pull request if you think it's okay and it works for my case.
I should also note, although it's obvious from looking at the code: this only fails if the call to X509_check_host
fails, and it drops down into the domain not in cert? try IP
code.
I'm pretty this check is wrong anyway, even if it werent' getting the segfault:
if (conn->sockaddr->sa_family == 4) len = 4;
else if (conn->sockaddr->sa_family == 6) len = 16;
sa_family
should be compared against the AF_INET
or AF_INET6
constants (from sys/socket.h
), not a literal 4
or 6
. These may vary from platform to platform.
Created PR #237 to address this bug.
My config file looks like this:
When I remove the
ssl_
stuff, it works fine. With it in, however, I get:Putting things up in GDB, I see the segfault here, in
ngx_http_auth_ldap_ssl_handshake_handler
:So
conn->sockaddr
is0x0
, hence the segfault.Let me know if you need more information. This is running in a docker container (Dockerfile) and was discovered as I was working on an enhancement for my project, idaholab/Malcolm#128
Here's the backtrace into the function: