mirror of
https://github.com/cesanta/mongoose.git
synced 2024-12-27 15:01:03 +08:00
Update OpenSSL handshake error codepath
This commit is contained in:
parent
38beb4cbc0
commit
e3589577ed
@ -14,7 +14,7 @@ CFLAGS += -L$(OPENSSL)/lib -lssl -lcrypto
|
||||
endif
|
||||
|
||||
all: $(PROG)
|
||||
$(DEBUGGER) ./$(PROG) $(ARGS)
|
||||
$(RUN) ./$(PROG) $(ARGS)
|
||||
|
||||
$(PROG): main.c
|
||||
$(CC) ../../mongoose.c -I../.. -W -Wall $(CFLAGS) -o $(PROG) main.c
|
||||
@ -22,7 +22,7 @@ $(PROG): main.c
|
||||
linux: all
|
||||
linux: CFLAGS += -O2 -g -fsanitize=address,undefined,shift,null,return,bounds,alignment,object-size,bool,enum -static-libasan
|
||||
linux: CC = $(LIN) cc
|
||||
linux: DEBUGGER = $(LIN)
|
||||
linux: RUN = $(LIN)
|
||||
|
||||
clean:
|
||||
rm -rf $(PROG) *.o *.dSYM *.gcov *.gcno *.gcda *.obj *.exe *.ilk *.pdb
|
||||
|
19
mongoose.c
19
mongoose.c
@ -3725,13 +3725,15 @@ static int rng_get(void *p_rng, unsigned char *buf, size_t len) {
|
||||
void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
|
||||
struct mg_tls *tls = (struct mg_tls *) calloc(1, sizeof(*tls));
|
||||
int rc = 0;
|
||||
const char *ca =
|
||||
opts->ca == NULL ? "-" : opts->ca[0] == '-' ? "(emb)" : opts->ca;
|
||||
const char *cert =
|
||||
opts->cert == NULL ? "-" : opts->cert[0] == '-' ? "(emb)" : opts->cert;
|
||||
const char *certkey = opts->certkey == NULL
|
||||
? "-"
|
||||
: opts->certkey[0] == '-' ? "(emb)" : opts->certkey;
|
||||
const char *ca = opts->ca == NULL ? "-"
|
||||
: opts->ca[0] == '-' ? "(emb)"
|
||||
: opts->ca;
|
||||
const char *cert = opts->cert == NULL ? "-"
|
||||
: opts->cert[0] == '-' ? "(emb)"
|
||||
: opts->cert;
|
||||
const char *certkey = opts->certkey == NULL ? "-"
|
||||
: opts->certkey[0] == '-' ? "(emb)"
|
||||
: opts->certkey;
|
||||
if (tls == NULL) {
|
||||
mg_error(c, "TLS OOM");
|
||||
goto fail;
|
||||
@ -3979,9 +3981,8 @@ void mg_tls_handshake(struct mg_connection *c) {
|
||||
LOG(LL_DEBUG, ("%lu success", c->id));
|
||||
c->is_tls_hs = 0;
|
||||
} else {
|
||||
int code;
|
||||
int code = mg_tls_err(tls, rc);
|
||||
ERR_print_errors_fp(stderr);
|
||||
code = mg_tls_err(tls, rc);
|
||||
if (code != 0) mg_error(c, "tls hs: rc %d, err %d", rc, code);
|
||||
}
|
||||
}
|
||||
|
19
src/tls.c
19
src/tls.c
@ -77,13 +77,15 @@ static int rng_get(void *p_rng, unsigned char *buf, size_t len) {
|
||||
void mg_tls_init(struct mg_connection *c, struct mg_tls_opts *opts) {
|
||||
struct mg_tls *tls = (struct mg_tls *) calloc(1, sizeof(*tls));
|
||||
int rc = 0;
|
||||
const char *ca =
|
||||
opts->ca == NULL ? "-" : opts->ca[0] == '-' ? "(emb)" : opts->ca;
|
||||
const char *cert =
|
||||
opts->cert == NULL ? "-" : opts->cert[0] == '-' ? "(emb)" : opts->cert;
|
||||
const char *certkey = opts->certkey == NULL
|
||||
? "-"
|
||||
: opts->certkey[0] == '-' ? "(emb)" : opts->certkey;
|
||||
const char *ca = opts->ca == NULL ? "-"
|
||||
: opts->ca[0] == '-' ? "(emb)"
|
||||
: opts->ca;
|
||||
const char *cert = opts->cert == NULL ? "-"
|
||||
: opts->cert[0] == '-' ? "(emb)"
|
||||
: opts->cert;
|
||||
const char *certkey = opts->certkey == NULL ? "-"
|
||||
: opts->certkey[0] == '-' ? "(emb)"
|
||||
: opts->certkey;
|
||||
if (tls == NULL) {
|
||||
mg_error(c, "TLS OOM");
|
||||
goto fail;
|
||||
@ -331,9 +333,8 @@ void mg_tls_handshake(struct mg_connection *c) {
|
||||
LOG(LL_DEBUG, ("%lu success", c->id));
|
||||
c->is_tls_hs = 0;
|
||||
} else {
|
||||
int code;
|
||||
int code = mg_tls_err(tls, rc);
|
||||
ERR_print_errors_fp(stderr);
|
||||
code = mg_tls_err(tls, rc);
|
||||
if (code != 0) mg_error(c, "tls hs: rc %d, err %d", rc, code);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user