[SOLVED] LNet TCP - upgrading to SSL connection lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- Dibo · 2009-12-19 15:36 Hi, I'm writing Jabber client. I'm using LNet TCP component. I attached session component with default value SSLActive: = False. Everything works ok, the client communicates with the server and it corresponds with right XML. I am now at a stage in which the server accepts SSL connection. I switch SSLActive to True but nothing happens. I trayed with all mode (SSL2/3 and TLS). TLSSLSessionComponent.OnSSLConnect event not trigger. How can I upgrade connection to SSL mode? Regards ---------------------------------------------------------------------- Almindor · 2010-05-06 15:22 Turnining on SSL usually requires both sides to agree to it (with TLS) or connect as such from the start (SSL mode). I'm not familiar with Jabber protocol but don't you need to tell the server to turn SSL on? Also what SSL version is expected (method). You can look in the examples/visual/smtp to get an idea on how to turn SSL on during connected phase (try TLS with google server). Hope this helps. Ales ---------------------------------------------------------------------- Dibo · 2010-08-28 22:09 After contact with you via e-mail, I write solution here which you give me. To activate TLS/SSL negotiation (if server allowed with command: ) just call: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i SSLSession.SSLActive := True;TCPClient.Iterator.SetState(ssSSLActive); I don't know why, maybe this is a bug, but this works only on first time. When I try connect second time, I get SIGSEGV error in OpenSSL.SslNew(ctx: PSSL_CTX):PSSL. I must destroy OpenSSL interface before next connection. So here is full solution without this error: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i uses OpenSSL; if IsSSLloaded then DestroySSLInterface; SSLSession.SSLActive := True;TCPClient.Iterator.SetState(ssSSLActive); Regards ---------------------------------------------------------------------- Almindor · 2011-03-02 20:37 Odd, I will try to get some way to recreate this problem on my end. Currently I'm trying to solve the HTTP/SSL problem in http://www.lazarus.freepascal.org/index.php/topic,7556.15.html perhaps it's related. With SMTP however, at least with smtp.gmail.com:587 it works fine for me (but that's just one connect, however SSL/TLS works nicely). ---------------------------------------------------------------------- Almindor · 2011-03-13 13:14 Can you try with latest trunk please? I'm about to release 0.6.5 after some SSL and disconnect related changes, and it's possible this bug was fixed along the way. Thanks ---------------------------------------------------------------------- evoshroom · 2012-07-08 20:38 Any chance I could get a copy of the Jabber/XMPP client using lnet for sockets? ---------------------------------------------------------------------- Shebuka · 2014-12-18 16:51 Hi, I'm trying to upgrade my connection to TLS and having serious problems. I have: Code: [Select]    FTCPSocket: TLTcp;     FSSLSession: TLSSLSession; and on FSSLSession.SSLActive := True; all is fine, but when I try to set FTCPSocket.Iterator.SetState(ssSSLActive); the app crashes. Debugging I found that when TLSSLSocket.SetupSSLSocket is called by TLSSLSocket.ActivateTLSEvent the FSSLContext is nil... with this FSSL := SSLNew(FSSLContext); produce a nil and I get SSLNew error (and then a crash in c := SslConnect(FSSL); of TLSSLSocket.ConnectSSL because there is no check if FSSL in nil). If I set FSSLSession.SSLActive := True; before calling connect all is working fine. Here is the same problem reproduced with lSMTPClient.pp when i press 't' after connection is established: Code: [Select]Anton-iMac:lsmtp fbk$ ./lsmtpclient smtp.gmail.com Connecting to smtp.gmail.com:25... Connected Press escape to quit Press "a" to authenticate (AUTH LOGIN) Press "e" to issue additional EHLO Press "t" to STARTTLS Press "return" to compose an email 220 mx.google.com ESMTP wz5sm9416924wjc.29 - gsmtp 250-mx.google.com at your service, [83.103.63.66] 250-SIZE 35882577 250-8BITMIME 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-CHUNKING 250 SMTPUTF8 SSLNew error 220 2.0.0 Ready to start TLS Lost connection I've tried calling FSSLSession.SSLActive := FUseTLS; and TLSSLSession(FTCPSocket.Session).SSLActive := FUseTLS; and even FTCPSocket.Session := FSSLSession; before FTCPSocket.Iterator.SetState(ssSSLActive); with no luck... Any suggestions to solve the problem? Mac OS X 10.10.1, Lazarus v2.6.2 svn rev.46797, lNet v0.6.5 svn (with some custom additions)