wqweto / VbAsyncSocket

Sockets with pure VB6 impl of TLS encryption
MIT License
164 stars 31 forks source link

cTlsClient example not work #1

Closed M2000Interpreter closed 3 years ago

M2000Interpreter commented 4 years ago

for this

 With New cTlsClient
   . SetTimeouts 0, 5000, 5000, 5000
    .Connect "smtp.gmail.com", 587
    Debug.Print .ReadText();
    .WriteText "HELO 127.0.0.1" & vbCrLf
    Debug.Print .ReadText();
    .WriteText "STARTTLS" & vbCrLf
    Debug.Print .ReadText();
    .StartTls "smtp.gmail.com"
    Debug.Print "TLS handshake complete: " & .TlsHostAddress
    .WriteText "QUIT" & vbCrLf
    Debug.Print .ReadText();
End With

we get this

220 smtp.gmail.com ESMTP l8sm10315047wmf.39 - gsmtp 250 smtp.gmail.com at your service 220 2.0.0 Ready to start TLS TLS handshake complete: smtp.gmail.com

but the example has one line more: 221 2.0.0 closing connection l8sm10315047wmf.39 - gsmtp

so we miss the clossing conection message

wqweto commented 4 years ago

Closing connection message comes from sending QUIT command. If you don't send this command the message is not received.

The project in test\Basic has a SMTP with STARTTLS button that shows hot to receive the final 221 2.0.0 closing connection s9sm2121200wme.36 - gsmtp message.

M2000Interpreter commented 4 years ago

I am running the test\Basic in a Windows 7 laptop. I get one of two messages (I have a bad wifi internet connection). 10733,861 Connect to port 587 10734,044 -> 220 smtp.gmail.com ESMTP c4sm23356653wru.31 - gsmtp 10734,302 <- HELO 46.103.248.123 10734,374 -> 250 smtp.gmail.com at your service 10734,382 <- STARTTLS 10734,448 -> 220 2.0.0 Ready to start TLS 10734,981 TLS handshake complete: smtp.gmail.com 10734,987 <- QUIT 10735,060 2746: An existing connection was forcibly closed by the remote host. at cTlsClient.ReadArray cAsyncSocket.SyncReceive

10745,868 Connect to port 587 10746,030 -> 220 smtp.gmail.com ESMTP j1sm39801749wrg.24 - gsmtp 10746,275 <- HELO 46.103.248.123 10746,372 -> 250 smtp.gmail.com at your service 10746,377 <- STARTTLS 10746,471 -> 220 2.0.0 Ready to start TLS 10747,515 TLS handshake complete: smtp.gmail.com 10747,519 <- QUIT 10747,584 80090302: The function requested is not supported at cTlsClient.pvTlsDecrypt DecryptMessage

wqweto commented 4 years ago

Ok, I see. I'll have to test it on Windows 7 when I find time to spare.

10x for the bug-report.

wqweto commented 4 years ago

FYI, cTlsClient is completely replaced by the new cTlsSocket class and the SMTP sample code is re-based on the new class.

This new class implemented TLS 1.3 client and server (plus legacy TLS 1.2 support for the client) as a drop-in source-compatible replacement of the original cAsyncSocket and is actively tested on NT4, Win2000 and WinXP for regressions.