]> SAFE projects GIT repository - jmp/mailleur/commitdiff
Opening tls in server mode is working
authorJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 3 May 2025 17:31:19 +0000 (13:31 -0400)
committerJean-Marc Pigeon (Delson) <jmp@safe.ca>
Sat, 3 May 2025 17:31:19 +0000 (13:31 -0400)
lib/devsoc.c

index 85765acdde42113a8688176756a7ed11f43b788d..8ed19e437718d479f199642dc95598009a24b931 100644 (file)
@@ -1377,6 +1377,7 @@ return socptr;
 PUBLIC _Bool soc_starttls(SOCPTR *socptr,_Bool server)
 
 {
+#define OPEP    "devsoc.c:soc_starttls,"
 _Bool ok;
 SOCTYP *soc;
 
@@ -1388,19 +1389,34 @@ if ((soc!=(SOCTYP *)0)&&(soc->modtls==false)) {
   char buffer[100];
 
   peerip=soc_getaddrinfo(socptr,false,false);
-  (void) usleep(100000);        //lets wait for 100 millisec
-  tosend=snprintf(buffer,sizeof(buffer),"%d 2.0.0 Ready to start TLS%s",
-                                        SIGNON,CRLF);
-  (void) soc_writebuffer(soc,buffer,tosend);
-  if ((soc->tls=tls_opentls(soc->handle,true))!=(TLSTYP *)0) {
+  switch (server)       {
+    case true   :
+      (void) usleep(100000);        //lets wait for 100 millisec
+      tosend=snprintf(buffer,sizeof(buffer),"%d 2.0.0 Ready to start TLS%s",
+                                            SIGNON,CRLF);
+      (void) soc_writebuffer(soc,buffer,tosend);
+      soc->tls=tls_opentls(soc->handle,true);
+      break;
+    case false   :
+      (void) rou_alert(0,"%s JMPDBG starting cleint mode",OPEP);
+      break;
+    }
+  if (soc->tls!=(TLSTYP *)0) {
     soc->proto=pro_smtps;
     soc->modtls=true;
-    (void) socpurge(soc,peerip);
     ok=true;
+    switch (server)       {
+      case true   :
+        (void) socpurge(soc,peerip);
+        break;
+      case false  :
+        break;
+      }
     }
   peerip=rou_freestr(peerip);
   }
 return ok;
+#undef  OPEP
 }
 /*
 ^L