#managing debugging test
TESTDIR = $(CURDIR)/test_area
+TESTSRV = mailleur.example.com
TESTIP = 127.127.10.25
TESTPORT= 1025
EXTIP = safemail3.safe.ca
$(TESTPORT) \
$(DATATST)/feed00.tst
#testing TLS connection
-testtls :
- openssl s_client \
+tlsrcvr :
+ @ clear
+ @ openssl s_client \
+ -status \
+ -msg \
+ -debug \
-CAfile certs/safe_CA.pem \
-cert certs/localhost_cert.pem \
-key certs/localhost_key.pem \
-starttls \
smtp
+xxx :
+ @ clear
+ @ openssl s_client \
+ -state \
+ -key certs/localhost_key.pem \
+ -cert certs/localhost_cert.pem \
+ -CAfile certs/safe_CA.pem \
+ -starttls smtp \
+ -connect $(TESTSRV):$(TESTPORT)
+
+# -showcerts
+# -connect mailprod1.safe.ca:25
+# -connect $(TESTSRV):$(TESTPORT)
+# -connect smtp.google.com:25
+#
+#testing TLS with google
+tlsref:
+ @ clear
+ @ openssl s_client \
+ -status \
+ -msg \
+ -debug \
+ -CAfile certs/safe_CA.pem \
+ -cert certs/localhost_cert.pem \
+ -key certs/localhost_key.pem \
+ -connect smtp.google.com:25 \
+ -starttls \
+ smtp
#--------------------------------------------------------------------
#starting email receiver
char buffer[100];
peerip=soc_getaddrinfo(socptr,false,false);
- (void) socpurge(soc,peerip);
+ (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) {
soc->proto=pro_smtps;
soc->modtls=true;
- (void) socpurge(soc,peerip);
+ //(void) socpurge(soc,peerip);
ok=true;
}
peerip=rou_freestr(peerip);
if (contact->tlsok==true)
strstart++;
for (int i=strstart;ehlostr[i]!=(char *)0;i++) {
- (void) transmit(contact,"%d%s",CMDOK,ehlostr[i]);
+ (void) rou_alert(0,"%s, JMPDNG i='%d'",OPEP,i);
+ (void) transmit(contact,"%d%s JMPDBG",CMDOK,ehlostr[i]);
}
done=true;
break;
switch (soc_starttls(contact->socptr)) {
case true : //link now in TLS crypted mode
contact->tlsok=true;
- (void) signon(contact);
+ (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",
switch (childs[i]) {
case -1 : //trouble trouble to fork?
childs[i]=(pid_t)0;
- (void) sleep(1); //Weathering the storm
+ (void) sleep(1); //Weathering the storme
break;
case 0 : //Child process itself
(void) free(childs);
//version definition
#define VERSION "0.6"
-#define RELEASE "45"
+#define RELEASE "46"
#define BRANCH "dvl"
//Public variables
while (proceed==true) {
switch (phase) {
case 0 : //get remote certificate
- if ((peer=SSL_get0_peer_certificate(tls->ssl))==(X509 *)0) {
- (void) rou_alert(0,"%s, Unable to get certificate from remote [%s]",
- OPEP,tls->peerip);
- phase=999;
+ if ((peer=SSL_get_peer_certificate(tls->ssl))==(X509 *)0) {
+ char msg[200];
+
+ (void) snprintf(msg,sizeof(msg),"%s, Unable to get certificate "
+ "from remote [%s]",
+ OPEP,tls->peerip);
+ (void) showtlserror(tls,0,msg);
+ phase=999; //no need to go furter
}
break;
case 1 : //displaying certificate
{
#define OPEP "unitls.c:set_link_certificate"
int done;
+int mode;
const char *certpub[3];
int phase;
_Bool proceed;
done=false;
+mode=SSL_VERIFY_NONE;
certpub[0]="./certs/safe_CA.pem"; //default and debugging certificats
//Default debugging server certificate
certpub[1]="./certs/mailleur_server_cert_x509.pem";
break;
case 4 : //verify management
(void) SSL_CTX_set_purpose(tls->ctx,X509_PURPOSE_ANY);
- (void) SSL_CTX_set_verify(tls->ctx,SSL_VERIFY_PEER,(int(*)())0);
+ (void) SSL_CTX_set_verify(tls->ctx,mode,(int(*)())0);
(void) SSL_CTX_set_verify_depth(tls->ctx,5);
(void) SSL_CTX_set_options(tls->ctx,SSL_OP_ALL);
if (SSL_CTX_set_cipher_list(tls->ctx,SSL_CIPHER_LIST)==0) {
phase=0;
proceed=true;
while (proceed==true) {
+ (void) rou_alert(0,"%s JMPDBG phase='%d', serveur='%d'",OPEP,phase,server);
switch (phase) {
case 0 : //prepare the structure first;
tls=(TLSTYP *)calloc(1,sizeof(TLSTYP));
status=0;
got=SSL_read(tls->ssl,buffer,maxread);
+ (void) rou_alert(0,"%S JMPDBG got='%d'",OPEP,got);
switch (got) {
case -1 : //trouble to write
- switch (status=SSL_get_error(tls->ssl,-1)) {
+ status=SSL_get_error(tls->ssl,-1);
+ (void) rou_alert(0,"%S JMPDBG status='%d'",OPEP,status);
+ switch (status) {
case SSL_ERROR_WANT_READ : //"wanted" error
case SSL_ERROR_WANT_WRITE : //
(void) usleep(1000);
+ (void) rou_alert(0,"%S JMPDBG usleep",OPEP);
break;
default :
(void) showtlserror(tls,-1,"%s Premature EOF with crypted link",OPEP);