Delphi Indy: cannot load SSL libraries first time. A retry works - delphi
I'm using the latest indy snapshot (installed yesterday) and newest SSL libraries.
When trying to send a mail using idSMTP, the first time the component connects, I get an exception:
Could't load the SSL libraries
. Funny thing is, a retry works always. Debugging I found that the problem is in IsSSLOpenSSLHeader, function Loaad: boolean, line
#OpenSSL_add_all_algorithms := LoadFunctionCLib('OpenSSL_add_all_algorithms');
Why does it fail the first time and not the second is still a mystery to me, but before I go on investigating I would like to as if anybody knows the solution to this problem.
The code you are using is NOT the latest snapshot. That bug was fixed a couple of weeks ago. The line you quote is NOT in the latest code, it has been replaced with the following:
fn_OPENSSL_add_all_algorithms_noconf = 'OPENSSL_add_all_algorithms_noconf';
fn_OpenSSL_add_all_algorithms = 'OpenSSL_add_all_algorithms';
#OpenSSL_add_all_algorithms := LoadOldCLib(fn_OpenSSL_add_all_algorithms, fn_OPENSSL_add_all_algorithms_noconf);
I'm using Delphi XE-1 on Win 7/64, with the SSL and Indy that are installed by default. This week I had to do some work with SMTP and SSL, and I ran into the same problem you reported. Our application is somewhat complex and is already live and deployed in several locations and it uses Indy at several points in the code, so installing a newer version of Indy and rebuilding etc, was not very palatable.
Since the problem only arises on the first pass, I traced through some of the code and came up with this simple, painless workaround:
smtpClient.connect;
smtpClient.disconnect;
smtpClient.connect;
if not smtpClient.Authenticate then
raise ...
smtpClient.Send(msg);
Once you call connnect and then disconnect, the SSL libraries are loaded, so on your second call to connect you're good to go.
Works fine.
Related
Indy server supports SSL 2, but it should not
Indy Delphi 10.1 Berlin. My customer had the HTTPS connection checked (using Qualys SSL Labs). The report states: "This server supports SSL 2" plus other warnings but I guess they are related to this. The code used is as follows: SSLIOhandler:=TIdServerIOHandlerSSLOpenSSL.Create(NIL); SSLIOhandler.SSLOptions.Method:=sslvTLSv1_2; SSLIOhandler.SSLOptions.Mode:=sslmServer; SSLIOhandler.OnVerifyPeer:=OnVerifyPeer; SSLIOhandler.SSLOptions.SSLVersions:=[sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2]; HTTPServer:=TIdHTTPServer.Create(NIL); HTTPServer.IOhandler:=SSLIOhandler; I have read various posts but this area remains pretty much abacadabra to me. I limited the SSLVersions to just [sslvTLSv1_2] but the warning remains. What else can I do? Update: Sorry to waste time. The Qualys test site apparently did not reload. I've restarted and retested and indeed it no longer complains about SSL2. Next step is to pass its complaints about the ciphers, starting with TLS_RSA_WITH_DES_CBC_SHA. I have a list of ciphers but can't find how to assign them. When I use e.g. SSLOptions.CipherList:='TLS_RSA_WITH_3DES_EDE_CBC_SHA'; I get an error: "SetCipher failed".
Datasnap Delphi XE7 - ApplyUpdates(0) issue
I have a datasnap server app developed originally with XE5 that was working fine with a client app on a mobile tablet accessing a Firebird database on a server. I have recompiled the code with XE7. The only change I had to make to the code to compile without any errors was to add DataSnap.DSProviderDataModuleAdapter to the uses of the methods unit. Have replaced the server app on the server (stop service/uninstall/reinstall/start service) and now I can no longer insert/update records in the database on the server. Whenever I reach the line of code to ApplyUpdates(0) I get the following error: Remote Error: Access violation at address 0093CB3F in module Snackerservice.exe. Read of address 00000000. Retrieving data from the database to display on the tablet is not a problem so the connection is working. If I change the server app back to the one developed under XE5......all works fine again. The other strange thing is that there are no problems with the XE7 compiled app when using 'localhost' to access a copy of the database on my development machine......only when accessing through an IP connection to a server. Can someone please help me solve this frustrating problem. Bill Zwirs To hopefully make it a little clearer, here is a bit of code that causes the issue: iLic := ServerMethodsClient.Get_Licences; iDev := ServerMethodsClient.Get_NumDevices; if (iDev < iLic) then begin iDevID := ServerMethodsClient.Get_NewDevID; MobClientDM.DevicesClient.Open; MobClientDM.DevicesClient.Insert; MobClientDM.DevicesClientDEVID.AsInteger:= iDevID; MobClientDM.DevicesClientMACADDRESS.AsString := sMacAddress; MobClientDM.DevicesClient.Post; if (MobClientDM.DevicesClient.ChangeCount > 0) then MobClientDM.DevicesClient.ApplyUpdates(0); ....................Error occurs here end;
Problem solved at last. When I installed the server app on the server I also added Midas.dll to the directory which worked fine until I compiled with XE7. So I have now included MidasLib in the uses clause of the server app and removed the Midas.dll file from the install directory. Compiled and installed and all works good again. Hope this helps others who might have a similar problem. Bill Zwirs
How to use component from the old indy9 package
I have upgraded Indy9 to Indy10 in Delphi7. Took some time for me to change all the parts with TCP servers and clients but seems like it works nice now. Now, i noticed one part is still not working, and thats idHTTPserver component. Our applications web page is using a mootools library. With Indy9 idHTTPserver it works perfectly, however Indy10 does something, which makes browsers fail to display the page. Besides some other errors, there is this nonsense error like (Firefox Error console output): Timestamp: 2013.08.07 13:13:56 Error: SyntaxError: missing ] after element list Source File: http://192.168.100.2:8780/lib/ui/core/mootools-1.2.4-more-yc.js Line: 103, Column: 60 Source Code: unction(){var b=["C?","C ","C","C?","C,","C¢","Cƒ","C£","C"","C¤","C.","C?","Ä,","ă","Ä"","Ä.","Ä?","Ä?","ÄŒ","Ĩ","C? -------------------------------------------------------------^ The actual source code inside this .js is: long long text ....... function(){var b=["C?","C ","C","C?","C,","C¢","Cƒ","C£","C"","C¤","C.","C?","Ä,","ă","Ä"","Ä.","Ä?","Ä?","ÄŒ","Ĩ","C?","C§","Ä?","ĸ","Ä","Ä'","Cˆ","CØ","C?","C©","CŠ","CR","C<","C«","Äš","Ä>","Ę","ÄT","Ä?","ÄŸ","CŒ","C¬","C¨","C","C?","C®","C¸","CÆ","Ĺ","Är","Ľ","ľ","Å","Å,","C'","C±","Å?","ň","Ń","Å"","C'","C²","C"","C³","C"","C´","C.","Cµ","C-","C¶","C˜","Cø","Å'","Ř","ÅT","Å"","Å.","Å ","Å?","Å?","ÅŸ","Åš","Å>","Ť","Å?","Ť","Å?","Å¢","Å£","CT","C¹","Cš","Cr","C>","C»","Cœ","C¼","Å®","ÅÆ","Åø","Cæ","C½","C¯","Ž","ž","Ź","År","Å»","ż","C?","C¾","C","C°","CŸ","Å'","Å"","C?","C¦","Aµ"]; ................ long long text What is happening here? I took a deep breathe and thought, hey i could just use the old version of idHTTPserver as i still have the source files of Indy9 in the other folder. If nobody knows how to fix the indy10 HTTPserver, could somebody please tell me how do i use the old version? Just the HTTPserver component (which surely links with 10s of other old indy files). I tried to include the old sources, but it was becoming a mess, because it would use the idHTTPserver.pas from old version, yet idCustomHTTPserver.pas (this is what happens after i follow the uses of idHTTPserver.pas file) from new version...
To use a different Indy version in one project, set the project search path to Indy\Lib\Core, \Protocols and \System, and instantiate all components in code. This also has the advantage that you can avoid the uninstall / install steps to switch between different Indy 10 versions.
While this is not the direct answer to my own question in title, this did solve my problem. I followed the function HTTPserver.WriteContent which led into idHTTPServer.pas, then compared idHTTPServer.pas files of Indy9 and Indy10, the parts about encoding in Indy10 caught my attention. At line 2039 i have removed the second argument of the write function FConnection.IOHandler.Write(ContentText, CharsetToEncoding(CharSet)); replaced with FConnection.IOHandler.Write(ContentText); This solved my problem. Everything works fine now. The main problem here was, as commenters have noticed, the extra " symbols. I was quite stupid because i clicked the link in the firefox console and it opened the javascript file which was of wrong version and for some reason i thought this was what it was supposed to be. Only a bit later i decided to check the actual file on my PC and it turned out that "C"" was not even C, the actual text is this var b=["À","à","Á","á","Â","â","Ã","ã","Ä","ä","Å","å","Ă","ă","Ą","ą","Ć","ć","Č","č","Ç","ç","Ď","ď","Đ","đ","È","è","É","é","Ê","ê","Ë","ë","Ě","ě","Ę","ę","Ğ","ğ","Ì","ì","Í","í","Î","î","Ï","ï","Ĺ","ĺ","Ľ","ľ","Ł","ł","Ñ","ñ","Ň","ň","Ń","ń","Ò","ò","Ó","ó","Ô","ô","Õ","õ","Ö","ö","Ø","ø","ő","Ř","ř","Ŕ","ŕ","Š","š","Ş","ş","Ś","ś","Ť","ť","Ť","ť","Ţ","ţ","Ù","ù","Ú","ú","Û","û","Ü","ü","Ů","ů","Ÿ","ÿ","ý","Ý","Ž","ž","Ź","ź","Ż","ż","Þ","þ","Ð","ð","ß","Œ","œ","Æ","æ","µ"]; So, i was right. When the whole text goes through CharsetToEncoding, it translates all these single symbol characters into 2 symbols. I will not accept my own answer as it doesnt really answer the title question and i would love to know if its possible to use a single component of older version while the rest are newer.
MonoDroid async service request
I think my issue is somehow related to the issue described in the post https://stackoverflow.com/questions/12526125/monodroid-wcf-request-response-of-2-asynch-requests-got-mixed. If it is so, the question is when it's going to be fixed. The MonoDroid 4.2.6 seems still having the issue. My exact problem is this. In the main action I start 5 async service requests. 4 service requests to one service and 1 service request to another service. Before sending the requests I add [ServiceName]Completed event listeners. The event listener for the service with one call is fired and two of the other event listeners are fired but they are fired twice. First time with the .Result equal null and the second time with the valid .Result object. The other two event listeners are never fired. On the service side I correctly receive all 5 requests and the service sends back all the responses. It is rather difficult to isolate the problem. Two many things were changed in the environment. The last version that worked was running on the Windows 7, using MonoDroid 4.2.4 and VS2010 was used for compiling the project. Now the problem is revealed under Windows 8, using MonoDroid 4.2.6 and VS2012 was used for compiling the project.
It does sound like this is a bug pure and simple in the Mono code. Looking at https://bugzilla.xamarin.com/show_bug.cgi?id=7200 it claims this is now available in 6.0.2 in the Beta channel. If you are still seeing the original problem, then contact Xamarin via Bugzilla - and via support#xamarin.com too if needed - it looks like they are keen to resolve the issue.
Please try Mono for Android 4.2.7, which has a number of related bug fixes.
cookies using Delphi 2010 and Indy
I'm new to dealing with cookies and not sure if my code or maybe Indy version is the problem based on researching other posts. Using Delphi 2010 and Indy 10.5.5. Have set up a cookiemanager at design time. I can send an initial login request (using the POST method) to the server that is successful (get a "success" code back from the server app) and the cookie manager shows that it has accepted a cookie from the server. When I try to reply to the server (again using POST) to get the next set of information, I get an error code back from the server app which indicates an authorization failure and I'm being told by the server tech support people to check the cookie being sent with the reply. How can I check the contents of the cookie header that is being sent back to the server? Also, in another post I saw that Indy 10 IdCookieManager.pas and IdCookie.pas have been updated in 2011. Should I update my Indy to the latest version as this might be my problem? Thanks in advance. Here is some more info: Thank you for your previous assistance; I appear to be getting closer to reinstalling Indy10. I purged my system of all Indy stuff except the most recent version (10.5.8) which I downloaded yesterday. [Actually I just moved the old stuff into a directory with an unusual name.] Now I get a clean compile on all 5 packages. I was able to add the two main packages (the ones starting with dcl) to my program's project list. But I get "[DCC Fatal Error] E2202 Required Package IndyCore not found." when I try to compile my main program. I tried removing and reinstalling the dcl packages to my project. When I removed them, I got the message that IndyCore and 3 other packages would also be removed - so it seems to know that dclIndyCode140 uses IndyCore140. I've added some directories to my search path and tried placing the 5 bpl's in different directories. None of that had any effect and at this point I am stumped. Ideas? Suggestions? Steve
Upgrading to the latest release is definate recommended. Links are on Indy`s website. Yes, cookie support was broken in earlier Indy 10 releases but it working again now. As for your other question, to see what TIdHTTP is sending, you have a few choices: Look at the TIdHTTP.Request.RawHeaders property after sending a request. Attach one of Indy's TIdLog... components to TIdHTTP, such as TIdLogFile, and look at the output. Use an external packet sniffer, such as Wireshark.