HTTPS Server with Indy 10, or some other library? lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- aidv · 2015-09-17 03:03 Ok, some of you might have followed my posts recently. First of all, Geepster, I want to thank you for sharing your code. Even though I never got your code snippets to work work with each other, your server code seems to work I think. Now I know what I need: I need a HTTPS server on my ARM Linux distro. I am trying to send data from an iPhone to a Raspberry Pi, and right now I am trying to send just simple parameters for a start. In XCode on my Mac, I get the following errorr: Code: [Select]2015-09-17 04:42:23.655 HTTPTest[1682:23914] CFNetwork SSLHandshake failed (-9847) 2015-09-17 04:42:23.658 HTTPTest[1682:23914] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9847) I am guessing that I need to set up my TIdHTTPServer to use SSL, right? How do I do that? I am currently reading about it and it says something about getting a certificate from a trusted source. Anybody wanna help me out? Jesus, this is just getting more and more complicated by the minute. ---------------------------------------------------------------------- taazz · 2015-09-17 03:19 Quote from: aidv on September 17, 2015, 05:03:14 amOk, some of you might have followed my posts recently. First of all, Geepster, I want to thank you for sharing your code. Even though I never got your code snippets to work work with each other, your server code seems to work I think. Now I know what I need: I need a HTTPS server on my ARM Linux distro. I am trying to send data from an iPhone to a Raspberry Pi, and right now I am trying to send just simple parameters for a start. In XCode on my Mac, I get the following errorr: Code: [Select]2015-09-17 04:42:23.655 HTTPTest[1682:23914] CFNetwork SSLHandshake failed (-9847) 2015-09-17 04:42:23.658 HTTPTest[1682:23914] NSURLSession/NSURLConnection HTTP load failed (kCFStreamErrorDomainSSL, -9847) I am guessing that I need to set up my TIdHTTPServer to use SSL, right? Wrong. Quote from: aidv on September 17, 2015, 05:03:14 amHow do I do that? by avoiding http all together (its a text based protocol and all text based protocols are not to be trusted for anything more than a hello) and go one level down to tcp. Android is linux based and linux is "secure" OS so forget all doors below 1024. You need to make sure that both your client and server are using any port above 1024. Quote from: aidv on September 17, 2015, 05:03:14 amI am currently reading about it and it says something about getting a certificate from a trusted source. Anybody wanna help me out? Not really you have shown an unwillingness to learn or study you have given working code for both a server and a client and you ended up unable to make them work. Putting everything aside I advice you to hire Geepster to write your server and client and be done with it. Oh by the way make sure that the server is  delivered as a block box compiled for your platform it will be easier for you to get started. If everything else fails keep the server out of the android and put the client on it. ---------------------------------------------------------------------- aidv · 2015-09-17 03:42 I am willing to hire Geepster, Thaddy wanted to give it a go as well. They can team up if they want to, I'll pay them both. And it's not for Android... yet... It's iPhone to ARM Linux (I know Android is originated to Linux). I'll be running Raspbian for now. And I'm not unwilling to learn, matter of fact I will take that as an insult because I am the one investing my time in this, and that time is at least 12 hours a day. AND, I am actually serving at port 1033, 1034, and 1035. So Geepster, if you see this, hit me up in a PM, my wallet is ready for you. And Thaddy. ---------------------------------------------------------------------- derek.john.evans · 2015-09-17 04:34 aidv, I'm not sure why you are having problems putting code together to achieve what you need. I'm not even sure you are clear as to what you actually need. eg: Considering you said you were not a "HTTP guru", how did you come to the decision that you now need HTTPS? That seems a little odd to me. Even at the HTTP level, or even TCP level, you still haven't indicated process triggers and possible user interaction. You just asked, how do I send a large file via TCP. ie: (2+Gig). That question, has been answered. Maybe, instead of flashing virtual cash on a "FREE" Pascal/Lazarus forum, where other people are also "investing their time", you could be a little more honest about what you want. By all means, hire someone if you so wish. People here are very honist about their work portfolio. Have a look though what people have done and contact them. But, maybe you need to contact them privately, and make an offer. Be prepared to pay a retainer, and provide adequate project documentation. Otherwise, be prepared to pay for a software design consultant. Isnt that what being professional is all about? ---------------------------------------------------------------------- aidv · 2015-09-17 05:27 Well, it's not a problem of putting code together, it's a problem of me being new to some technologies, and as a human being I am allowed to learn new things and step in to the unknown, right? If I'd be having problems with putting code together I wouldn't have learned how to do programming in XCode in just 4 weeks starting from nothing. Take it easy my friend, we all have to start somewhere. So.. Firstly, apparently Apple doesn't like HTTP and only accepts HTTPS according to some articles and Thats how I came to the conclusion of the HTTPS requirement. Secondly regarding HTTPS, it's supposed to be secure, and consumers need secure products. On a TCP level: I have already something that works 90% of the time that I did completely on my own so please don't tell me that I haven't indicated anything, but I'm not happy with 90%, I want close to 100%. And even "close to 100%" won't satisfy me, it MUST be 100% because I care about my customers. Once again it is a commercial product so I won't skimp on quality, please understand that. And excuse me but what do you mean by "flashing virtual money"? If I say I will pay then take my word for it, I will most certainly pay. Nobody will work for free and I know it and I respect it. And plus I said yesterday that I will try whatever help I've gotten first, and if I still fail, THEN I will be hiring someone. And I respect people investing their time too, but claiming and judging me because I don't understand some aspects of programming is simply put disrespectful. How did you learn all your knowledge? Were you born with a Programming Guide or what? (not you specifically, but people in general) And I do know what I want, and I've stated it several times before: Send files in chunks from machine A to machine B with a ultra-low failure rate. If security can hop on the bandwagon, the HTTPS would be a good candidate. I'll make a public offer, and whoever feel like he or she can take on the project is welcome to contact me. I am not obligated to contact anyone, and nobody is obligate to contact me, I just put it out there, like an Ad, you know. Finally: I don't know what unprofessionalism has to do with anything. Just because I ask for help and don't quite get my project to work as I expect it to work makes me unprofessional? Or am I unprofessional because I don't go to the first consultant I see that will want at least 5000€ out my a** for a week worth of work? I came here because I like the atmosphere here and people are always helpful here, there is absolutely Nothing wrong with me "flashing virtual money" as you call it and try to partner up with someone. At least I have one candidate, and that person seems really interested, which is fun. This isn't a homebrew hackaware project my friend, I am very specific in what I want and if I find info on technologies that can benefit my project, such as HTTPS, then I'll switch route until I'm done with it and feel satisfied. So if you don't want to waste your time helping me for free anymore, feel free to give me an offer, I've mentioned it several times before. Or simply say "No thanks" and ignore me regarding this specific subject. And the reason I am making an offer here and not go to a consultant is because Why Not? I can do whatever I want, I can ask whoever I want, maybe someone here is struggling with getting a paid project and now might be his or her chance. ---------------------------------------------------------------------- rvk · 2015-09-17 08:23 Quote from: aidv on September 17, 2015, 07:27:37 amAnd I do know what I want, and I've stated it several times before: Send files in chunks from machine A to machine B with a ultra-low failure rate. If security can hop on the bandwagon, the HTTPS would be a good candidate. May I trow in my 0.02$ again... You still don't get the point that, if your TCP solution fails 10% of the time, HTTPS will also fail. It's just that the code of Geepster has build in re-sends when a chunk failt. You could/should implement that too with your current solution. Another problem is that you keep asking something but show very little in terms of analyzing/debugging what's really wrong. You say Apple doesn't like HTTP (?) but that's it. You don't show your code, you don't show any errors. We can't do anything with that. You ask for a solution and Geepster has provided one. If you would set out a job- offer you would get the same: A working solution for the developer which might or might not work for you  That said... Apple (and Linux) doesn't like if you use anything below port 1024 if you're not an administrator. If you want to run your program/server as a user you need to use a port > 1024. I tried the code Geepster gave you and with some modification I got it working from Windows to Linux. Below are the modifications I made. If you gave us some more information as to WHERE you are having trouble (code examples, error messages) we could have helped you much more efficiently. Now for the modifications: If you want to use port > 1024 (6501 for example) you need to use this: Code: [Select]    SendFile('http://192.168.1.44:6501/result.mp4', 'D:\ISOs\Windows 7\X17-59463.iso', $1000000); The only thing where Geepster code laks is that it doesn't add the port it extracted in TIdURI back to the LRemotePath in SendFile(). So change this: Code: [Select]  procedure SendFile(const AURI: TIdURI; const AStream: TStream; const AChunkSize: Integer);   //...     LRemotePath := AURI.Protocol + '://' + AURI.Host + ':' + AURI.Port + AURI.Path; (note the + ':' + AURI.Port part) Then on the receiving end (the server). You need to make sure the binding for TFileServer is port 6501 and IPv4 (not sure if you already have a mixed IPv4/IPv6 environment). Al you need to change is this: Code: [Select]var   Binding: TIdSocketHandle;   FileServer: TFileServer; begin   FileServer := TFileServer.Create(nil);   try     Binding := FileServer.Bindings.Add;     Binding.IPVersion := Id_IPv4;     Binding.IP := '192.168.1.44';     Binding.Port := 6501;     FileServer.Active := True;     WriteLn('Server started');     ReadLn;   finally     FileServer.Free;   end; end. As said... this works with Windows 10 sending (client) and Debian receiving (server) on port 6501. I successfully send a file of 2GB. So it should work on a Mac too. If not... please provide exact information of what is not working, error messages etc. Edit: B.T.W. I would add some visual check for the errors. If you still get errors you need to check your cabling or other network- components. I didn't get one single error in my sending of a 2GB file and you shouldn't either. There is error-checking in place but you shouldn't just rely on that. When getting errors something is seriously wrong with your setup. Code: [Select]      Write('.');       StreamHttpPut(AStream, AUrl);       if HttpGetMD5(AUrl) = MemoryStreamGetMD5(AStream) then begin         Exit;       end;       Dec(ATryCount);       Writeln('');       Writeln('Error'); ...     writeln('');     writeln('Waiting on final MD5'); // <-- can take some time for a 2GB file     if HttpGetMD5(AURI.URI) <> MD5Print(MD5File(AFileName)) then begin       raise Exception.Create('Final MD5 Check Failed');     end; ---------------------------------------------------------------------- JD · 2015-09-17 09:06 Quote from: aidv on September 17, 2015, 07:27:37 amAnd I do know what I want, and I've stated it several times before: Send files in chunks from machine A to machine B with a ultra-low failure rate. I would advise you to reconsider TCP. It ensures that what is sent is delivered. Read this wikipedia article if you need further proof. https://en.wikipedia.org/wiki/Transmission_Control_Protocol JD ---------------------------------------------------------------------- aidv · 2015-09-26 12:23 After a week of programming I managed to get it to work properly. I have created my own protocol on top of TCP and I can send (what seems like) unlimited sized data without a problem. Thanks again to everyone that have taken the time to help me. I used Indy 10 as it seems to be a lot more reliable than LNet.