diff options
author | Simon Rettberg | 2015-04-28 17:55:27 +0200 |
---|---|---|
committer | Simon Rettberg | 2015-04-28 17:55:27 +0200 |
commit | 7408a04e740e9b54747bb6333ee9f9ecd098e958 (patch) | |
tree | 39da0f7a253ea5f7722695fe7e31ada8ba119990 | |
parent | SSL support when talking to ADS (diff) | |
download | ldadp-7408a04e740e9b54747bb6333ee9f9ecd098e958.tar.gz ldadp-7408a04e740e9b54747bb6333ee9f9ecd098e958.tar.xz ldadp-7408a04e740e9b54747bb6333ee9f9ecd098e958.zip |
Fix SSL mode :)
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | openssl.c | 7 | ||||
-rw-r--r-- | openssl.h | 2 | ||||
-rw-r--r-- | proxy.c | 4 | ||||
-rw-r--r-- | server.c | 4 |
5 files changed, 16 insertions, 6 deletions
@@ -26,11 +26,12 @@ scan_ldapsearchfilterstring.o free_ldapsearchresultentry.o \ fmt_ldapsearchfilterstring.o ldap_match_sre.o \ fmt_ldapdeleterequest.o scan_ldapdeleterequest.o normalize_dn.o -CC=gcc +CC?=gcc CFLAGS=-g -pipe -W -Wall -Wextra -std=gnu99 -Wno-unused-parameter #CC=clang #CFLAGS=-g -pipe -fsanitize=address -O1 -fno-omit-frame-pointer -W -Wall -Wextra -std=gnu99 -Wno-unused-parameter -LIBS+=-lowfat -lssl -lcrypto + +LIBS+=-g -lowfat -lssl -lcrypto %.o: %.c $(CC) $(CFLAGS) -c $< @@ -93,9 +93,14 @@ BOOL ssl_connectServer(epoll_server_t *server) server->sslConnected = TRUE; return TRUE; } - if (ret < 0) { + if (ret <= 0) { int err = SSL_get_error(server->ssl, ret); if (SSL_BLOCKED(err)) return TRUE; + if (err == SSL_ERROR_SSL) { + ssl_printErrors(NULL); + } else { + printf("SSL Unknown error %d\n", err); + } } return FALSE; } @@ -5,7 +5,7 @@ #include <openssl/ssl.h> #include <openssl/err.h> -#define SSL_BLOCKED(err) ((err) == SSL_ERROR_WANT_READ || (err) == SSL_ERROR_WANT_WRITE || (err) == SSL_ERROR_WANT_X509_LOOKUP) +#define SSL_BLOCKED(err) ((err) == SSL_ERROR_WANT_READ || (err) == SSL_ERROR_WANT_WRITE || (err) == SSL_ERROR_WANT_X509_LOOKUP || (err) == SSL_ERROR_WANT_CONNECT || (err) == SSL_ERROR_WANT_ACCEPT) void ssl_printErrors(char *bailMsg); @@ -176,7 +176,9 @@ BOOL proxy_fromServer(epoll_server_t *server, const size_t maxLen) unsigned long messageId, op; size_t len; const size_t res = scan_ldapmessage(server->readBuffer, server->readBuffer + maxLen, &messageId, &op, &len); - if (res == 0) return FALSE; + if (res == 0) { + return FALSE; + } printf("[AD] scan_ldapmessage: Consumed %d, remaining length %d, id %lu, op %lu\n", (int)res, (int)len, messageId, op); switch (op) { case BindResponse: @@ -343,7 +343,7 @@ static void server_haveIn(epoll_server_t *server) if (consumed == 0) break; // Length-Header not complete len += consumed; if (len > server->rbPos) break; // Body not complete - printf("[AD] Received complete reply...\n"); + printf("[AD] Received complete reply (need %d, have %d)...\n", (int)len, (int)server->rbPos); if (!proxy_fromServer(server, len)) { if (server->dynamic) { server->kill = TRUE; @@ -416,6 +416,8 @@ static void server_haveOut(epoll_server_t * const server) if (SSL_BLOCKED(err)) { server->writeBlocked = TRUE; return; // Blocking + } else if (err == SSL_ERROR_SSL) { + ssl_printErrors(NULL); } printf("SSL server gone while sending (%d)\n", err); ERR_print_errors_fp(stdout); |