From cab9bb3edb2e8e62e654e2d715cff628d8c5fa79 Mon Sep 17 00:00:00 2001 From: "Jean-Marc Pigeon (Delson)" Date: Sun, 4 May 2025 08:23:27 -0400 Subject: [PATCH] certificate recognition is working fine --- Makefile | 2 +- app/feeder.c | 6 +++--- lib/devsoc.c | 24 +++++++++++------------- lib/lvleml.c | 2 -- lib/subrou.h | 4 +++- lib/unitls.c | 7 ++----- 6 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index 3a33738..b84f4ae 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ extfeed : debug onefeed : debug @ bin/feeder \ -f \ - -d3 \ + -d2 \ $(TESTIP) \ $(TESTPORT) \ $(DATATST)/feed00.tst diff --git a/app/feeder.c b/app/feeder.c index 32239fe..3ca0523 100644 --- a/app/feeder.c +++ b/app/feeder.c @@ -229,7 +229,7 @@ return status; static _Bool doincoming(SOCPTR *socptr,int numline,char *line) { -#define OPEP "tstfeed.c:doincoming" +#define OPEP "feeder.c:doincoming" #define STRETC "..." _Bool status; @@ -262,7 +262,7 @@ while (proceed==true) { case 1 : //waiting for a line with CRLF received=(char *)0; got=tcp_getline(socptr,WAITLINE,&received); - (void) rou_alert(0,"%s, received=<%s>",OPEP,received); + (void) rou_alert(3,"%s, received=<%s>",OPEP,received); switch (got) { case 0 : //Reading timeout (void) rou_alert(0,"Unable to receive line in due time"); @@ -327,7 +327,7 @@ _Bool proceed; status=true; phase=0; proceed=true; -(void) rou_alert(0,"%s line=<%s>",OPEP,line); +(void) rou_alert(3,"%s line=<%s>",OPEP,line); while (proceed==true) { switch (phase) { case 0 : //removing first space diff --git a/lib/devsoc.c b/lib/devsoc.c index a4dd9d5..d673b9f 100644 --- a/lib/devsoc.c +++ b/lib/devsoc.c @@ -915,31 +915,28 @@ SOCTYP *soc; status=-2; soc=(SOCTYP *)socptr; if ((soc!=(SOCTYP *)0)&&(isconnected(soc)==true)) { - struct pollfd polling[1]; - - polling[0].events=POLLIN|POLLPRI|POLLHUP; - polling[0].revents=(short)0; switch (soc->modtls) { case true : - (void) rou_alert(0,"%s JMPDBG Waiting TLS",OPEP); status=tls_waitforchar(soc->tls,millisec); break; - case false : + case false : { + struct pollfd polling[1]; + + polling[0].events=POLLIN|POLLPRI|POLLHUP; + polling[0].revents=(short)0; polling[0].fd=soc->handle; (void) sigprocmask(SIG_SETMASK,(sigset_t *)0,&origmask); status=poll(polling,1,millisec); (void) sigprocmask(SIG_SETMASK,&origmask,(sigset_t *)0); + } break; } switch (status) { case -1 : //polling error - (void) rou_alert(0,"%s JMPDBG Poll error=<%s>",OPEP,strerror(errno)); break; case 0 : //polling timeout - (void) rou_alert(0,"%s JMPDBG Polling timeout",OPEP); break; case 1 : //polling early return (data or event) - (void) rou_alert(0,"%s JMPDBG Polling return",OPEP); break; default : break; @@ -1125,13 +1122,14 @@ while (proceed==true) { if (errno==EWOULDBLOCK) errno=EAGAIN; switch (errno) { - case EAGAIN : //no char available yet - got=0; //lets report "no char" + case ITSOK : //SSL report (wrong) error? + case EAGAIN : //no char available yet + got=0; //lets report "no char" break; - case ECONNRESET : //Connection reset by peer + case ECONNRESET : //Connection reset by peer (void) rou_alert(0,"%s connection reset by peer",OPEP); break; - default : + default : (void) rou_alert(0,"%s Unexpected error=%d <%s> (Bug)", OPEP,errno,strerror(errno)); break; diff --git a/lib/lvleml.c b/lib/lvleml.c index e67ced1..7837edd 100644 --- a/lib/lvleml.c +++ b/lib/lvleml.c @@ -419,7 +419,6 @@ while (proceed==true) { switch (soc_starttls(contact->socptr,true,srvr_certs)) { case true : //link now in TLS crypted mode (void) transmit(contact,"%d Link now encrypted",CMDOK); - (void) rou_alert(0,"%s, CMDOK sent",OPEP); break; case false : //unable to establish link (void) transmit(contact,"%d 5.3.3 command starttls not successful", @@ -437,7 +436,6 @@ while (proceed==true) { QUITOK,contact->mainsesid); status=-1; //remote is a trouble maker proceed=false; - (void) rou_alert(0,"%s JMPDBG should ho out",OPEP); break; default : (void) rou_alert(0,"Unable to find keyword for <%s> (Bug?)",OPEP,line); diff --git a/lib/subrou.h b/lib/subrou.h index 0cd86a3..5c0b5fa 100644 --- a/lib/subrou.h +++ b/lib/subrou.h @@ -13,10 +13,12 @@ #include -#define APPNAME "mailleur" //application name +#define APPNAME "mailleur" //application name #define PUBLIC //to specify public variable +#define ITSOK 0 //to check errno against no error + typedef void (*freehandler_t)(void *); typedef struct timespec TIMESPEC; diff --git a/lib/unitls.c b/lib/unitls.c index 588c8c3..c0a9fc6 100644 --- a/lib/unitls.c +++ b/lib/unitls.c @@ -428,7 +428,6 @@ while (proceed==true) { case 3 : //Setting the TLS channel actif switch (server) { case false : //mode client - (void) rou_alert(0,"%s JMPDBG should be in client mode",OPEP); if (tls_connect(tls)<0) phase=999; //trouble trouble break; @@ -601,8 +600,9 @@ if (tls!=(TLSTYP *)0) { break; } break; - case 0 : //no char sent + case 0 : //no char received switch (SSL_get_error(tls->ssl,0)) { + case SSL_ERROR_ZERO_RETURN : //No char available on link case SSL_ERROR_SYSCALL : //EOF received? tls->goteof=true; if (ERR_get_error()!=0) @@ -713,7 +713,6 @@ statut=-1; peer=(X509 *)0; tic=30; //30 second MAX to extablish SSL connexio done=false; -(void) rou_alert(0,"%s JMPDBG in tls_accept",OPEP); if ((tls->bio=BIO_new_fd(tls->handle,BIO_NOCLOSE))==(BIO *)0) { (void) rou_core_dump("%s Unable to get the BIO (error=<%s>)", OPEP,strerror(errno)); @@ -726,9 +725,7 @@ while (done==false) { switch (sslerr=SSL_get_error(tls->ssl,statut)) { case SSL_ERROR_NONE : statut=0; - (void) rou_alert(0,"%s JMPDBG ask for Peer",OPEP); if ((peer=SSL_get_peer_certificate(tls->ssl))!=(X509 *)0) { - (void) rou_alert(0,"%s JMPDBG Got Peer",OPEP); if (SSL_get_verify_result(tls->ssl)!=X509_V_OK) statut=-1; (void) X509_free(peer); -- 2.47.3