Submit a form over secure socket ssl and get result lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- jack · 2012-08-09 01:24 I need to submit a form to my website and receive the response. I found synapse and with it an excellent example of simplicity using httpsend that worked. Now I would like to move that example to SSl using https.  Not so fast, there is no httpssend ! So there must be more to it than just finding a new synaps module? Since I learn best by example.  I have been searching for an example of code using HTTPS.  Hopefully code as simple as that I found for httpsend. Can anyone point me to an example? I just want to submit a form with half dozen string fields and recieve the response string. Yes we do have a cert and yes we can do this from a browser without problems. ================================= Here is the example that I have tested and it works without SSL. ======== procedure TForm1.Button1Click(Sender: TObject); var    programName  : String;    date         : String;    submitString : String;    resultstream: TStringStream; begin    programName  := ExtractFileName(ParamStr(0));    date         := FormatDateTime('mm/dd/yyyy', now);    submitString := 'programName=' + programName + '&pcDate='+date;    resultstream := TStringStream.Create('');    try       if httpPostURL('http://mysite.com/directory/index.php', submitString, resultstream) then          edit2.text := resultstream.DataString       else          edit2.text := 'httpPostURL failed';    finally       resultstream.Free;    end; end; ============================= Thank you for your time and I hope you can show me an example. ---------------------------------------------------------------------- ludob · 2012-08-09 06:11 You just add ssl_openssl to the uses clause of the program and httpsend will also work with https. The reason for this simplicity is that httpsend is already ssl aware but doesn't have a default ssl implementation. Synapse supports different ssl implementations with openssl and cryptlib the best known ones. So you just need to tell Synapse which implmentation to use. Openssl has the most liberal licence. Be sure to have the openssl libraries accessible from the app. ---------------------------------------------------------------------- jack · 2012-08-09 12:44 Going with LAZARUS is looking more and more like a very good decision. Thanks for the response. ---------------------------------------------------------------------- jack · 2012-08-09 13:05 When testing with the suggested ssl_openssl added to the uses statement I got a strange reply from somewhere. If I use a url of http://myserver.com/index.php I get the expected result. If I use a url of https://myserver.com/index.php I get "Fix old link". This response is Not from my php program. Any thoughts are appreciated. ---------------------------------------------------------------------- ludob · 2012-08-09 15:04 If you didn't change anything else to the code then the message is coming from your server. How is the server set up? There are different things that can go wrong. For example the DocumentRoot for the *:443 virtual host could be different from the *:80 virtual host (apache).  Is connection with a normal browser working and is the url in the address field of the browser the same as you entered. If it is different then you have probably a redirection which you have to deal with. Synapse doesn't do redirections automatically. Another source of information are the web server logs.  The disadvantage of convenience functions like httpPostURL is that a lot of status messages and headers are hidden from you. Creating your own Httpsend object gives far more flexibility and information.  If you look at the source code of httpPostURL you'll see immediately what is involved. Creating your own httpsend object allows also for connection re-use which is a big performance boost when you have a lot of interaction with the webserver. https connection setup takes quite some time. ---------------------------------------------------------------------- jack · 2012-08-09 16:38 Thanks I am off to talk with the server folks.