File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ CC = gcc
2+ CFLAGS = -Wall -Wextra -fPIC
3+ LDFLAGS = -shared
4+ LIBS = -lssl -lcrypto -ldl -lupkiopenssl -L../target/release/
5+
6+ TARGET = libupkiopenssl-preload.so
7+ SOURCE = preload.c
8+
9+ .PHONY : all clean
10+
11+ all : $(TARGET )
12+
13+ $(TARGET ) : $(SOURCE ) upki-openssl.h
14+ $(CC ) $(CFLAGS ) $(LDFLAGS ) -o $@ $(SOURCE ) $(LIBS )
15+
16+ clean :
17+ rm -f $(TARGET )
18+
19+ install : $(TARGET )
20+ install -m 755 $(TARGET ) /usr/local/lib/
21+
22+ uninstall :
23+ rm -f /usr/local/lib/$(TARGET )
Original file line number Diff line number Diff line change 1+ #include "upki-openssl.h"
2+ #include <dlfcn.h>
3+ #include <openssl/ssl.h>
4+
5+ typedef SSL * (* ssl_new_fn )(SSL_CTX * );
6+
7+ SSL * SSL_new (SSL_CTX * ctx ) {
8+ void * parent = dlsym (RTLD_NEXT , "SSL_new" );
9+ if (!parent ) {
10+ return NULL ;
11+ }
12+
13+ SSL * new = ((ssl_new_fn )(parent ))(ctx );
14+ if (!new ) {
15+ return new ;
16+ }
17+
18+ // TODO: save and call current too.
19+ // SSL_verify_cb current = SSL_get_verify_callback(new);
20+ int mode = SSL_get_verify_mode (new );
21+ SSL_set_verify (new , mode , upki_openssl_verify_callback );
22+ return new ;
23+ }
24+
25+ // TODO: also hook later calls of SSL_set_verify, SSL_get_verify_callback
You can’t perform that action at this time.
0 commit comments