Indy SSL to plain socket pump

I have to provide an SSL front for a plain TCP server, so I'm making a "pump" application that will provide an SSL connection to the outside while the original server can stay plain.

I'm trying to use the Indy components to support my SSL needs, but I can't seem to get any data from the SSL port. I assigned the TIdTCPServer.OnExecute to the following event handler:

procedure TForm1.IdTCPServer1Execute(AContext: TIdContext); var c:TIdTCPClient; cs,ss:TIdIOHandler; b:TBytes; begin c:=TIdTCPClient.Create(Self); try c.Host:=''; c.Port:=60675; c.ConnectTimeout:=500; c.Connect; ss:=c.IOHandler; cs:=AContext.Connection.IOHandler; while (cs.Connected) and (ss.Connected) do begin if cs.CheckForDataOnSource(1) then begin try cs.ReadBytes(b,1,False); except on e:Exception do Memo1.Lines.Add(e.Message); //BAD out of Thread context end; if Length(b)>0 then ss.Write(b); end; if ss.CheckForDataOnSource(1) then begin ss.ReadBytes(b,1,False); if Length(b)>0 then cs.Write(b); end; end; finally c.Free; end; end;

The TCP server has an SSL handler attached. I did the same on a plain HTTP server and it worked fine, so I'm assuming my SSL setup is not the issue.

cs=Client Side (the server socket) and ss=Server side (the client for the TCP server I'm trying to add SSL to).

Now, I know it needs cleanup and doing 1ms waits isn't pretty, but before I can attack that issue, I'd like to receive some data.

Neither of my ReadBytes get called. When I used cs.Readable(), I get true just once, but I still couldn't read.

What can I do to make a pump? Why am I not getting data?


Try using the TIdMappedPortTCP component instead of TIdTCPServer directly. TIdMappedPortTCP handles all the work of passing data back and forth between a client and another server. By default, the outbound connection to the second server is not encrypted, even if the inbound connection to TIdMappedPortTCP is encrypted.

Category:delphi Time:2011-10-10 Views:5
Tags: ssl delphi indy

Related post

  • Is it possible to change plain socket to SSLSocket? 2011-07-02

    There is a plain socket server listening on port 12345; ServerSocket s = new ServerSocket(12345); What I want to know is that it is possible that: If the client send a http request, the server handle the request directly, If the client send a https r

  • Random Indy ResponseCode = -1 / EIdSocketError Socket Error # 0 exceptions 2012-04-26

    I have a delphi code that basically upload files to remote secure server using Indy 10.4.704: IdHTTP := TIdHTTP.Create(nil); try TheCompressor := TIdCompressorZLib.Create(nil); TheSSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil); with IdHTTP do begin

  • Delphi 6 and Indy SSL connection not working 2009-09-14

    I need to consume a Web Service via SSL. In order to accomplish that I have built a web client in Delphi 6 that uses Indy to read the client certificates and write the soap request via https. The compilated version of the code is a DLL that runs in I

  • Does Indy support raw TCP sockets on Windows? 2009-11-02

    I'm a C++ programmer, but my question is about the Delphi network socket library Indy. Essentially as Microsoft crippled raw sockets with WinXP SP2 so that TCP data cannot be sent over them, does this then also apply to Indy? One of my friends recomm

  • NSStream SSL on used socket 2010-02-10

    I am writing an application that uses NSStream's SSL functions on the iphone. I know that SSL is working because I can directly connect servers using SSL. I have encountered a problem where protocols that use starttls require me to communicate on the

  • Error: Event ID 15021, httpEvent.__An error occured while using SSL configuration for socket address The error status code is contained within the returned data. 2014-03-23

    hey, i got this problem for 2 weeks, when i'm using the internet, after couple of minutes or hours Windows stops with a blank blue screen and sometimes restarts it self, sometimes stay on that screen. Event Viewer, shows me that the firewall faild to

  • Is it possible to send HTTP request using plain socket connection and receive response without headers? 2011-11-30

    experts I am trying to implement a downloader which handles HTTP protocol, I am able to send HTTP request using the following code: StringBuilder request = new StringBuffer().append("GET ").append(uri.getPath()); if(uri.getQuery() != null) request.ap

  • SSL and NIO Non-blocking Sockets 2009-11-14

    How do you recommend making a highly scalable SSL client? Currently, I'm using plain Sockets to connect to the Apple APNS server which requires a non-HTTP SSL sockets. I considered using the NIO library, but it is lacking a SSLSocketChannel, and I co

  • Java SSL sockets without authentication or stores? 2010-03-09

    I have two java applications that need to talk to each other over an encrypted TCP socket, but they don't need to authenticate each other (one will accept() a connection from the other). Can anyone point me to a tutorial/code-snippet that will help m

  • SSL Socket connect timeout 2011-04-19

    How can I configure connect timeout for SSL Sockets in Java? For plain sockets, I can simply create new socket instance without any target endpoint using new Socket(), and then call connect(SocketAddress endpoint, int timeout) method. With SSL socket

  • Delphi 5 Indy/ics SSL workaround? 2011-10-26

    I'm getting errors like: "IndyProtocols5 does not use or support IdSSLOpenSSLHeaders.." when attempting to install Indy 9 or 10 with my Delphi5 and notice it is a problem for others. This causes the exception: "Could not load SSL library" when using

  • Error ID: 0x800CCC0E Protocol: SMTP Port: 587 Secure(SSL): No Socket Error: 100 2014-12-13

    I am unable to send messages in WLM and get the following message ""The connection to the server has failed. Subject 'xxx' Server: '' Windows Live Mail Error ID: 0x800CCC0E Protocol: SMTP Port: 587 Secure(SSL): No Socket Error: 10

  • How can I connect to server using SSL(secure socket layer) on .NET Compact Framework 2010-03-29

    I want to change .NET framework v3.5 to .NET compact framework v3.5. But I can't change SSL Stream class to compact framework version. For resolving this problem, I already read some article and msdn library.

  • SSL socket connection on iPhone 2010-04-19

    Is there a way to reuse SSL socket connections on the iPhone. I'm seeing an extra 3-4 second overhead in doing SSL handshaking. I'm using NSURLconnection currently to do the API calls and each one of them is taking 4-5 seconds on Wifi. Any suggestion

  • boost asio ssl stream socket compilation issue 2010-04-29

    Using boost 1.4.2 asio in a c++ app and getting linux compiler warnings i don't grok. still here? The app i'm working on needs a "socket" that might be an ssl socket or a regular tcp socket so we hide specifics behind a template "socket" class that t

  • Using client/server certificates for two way authentication SSL socket on Android 2010-10-31

    I'm working on an Android app that requires both client and server certificate authentication. I have an SSLClient class that I created that works beautifully on regular desktop Java SE 6. I've moved it into my Android project and I'm getting the fol

  • How do I make an SSL socket available between functions? 2010-11-30

    This is my class: class SSLIRC : public Bot { public: SSLIRC(void); void sockconnect(char*, int, bool); void sockwrite(char*); std::string sockread(void); bool connected; bool verbose; private: WSADATA wsaData; SOCKET m_socket; sockaddr_in clientServ

  • ssl. is it able to add/remove ssl from a bsd socket? 2011-04-06

    I'm looking at openssl example in c. It looks like I can first create a regular bsd socket, and add ssl capability on top of it. /* Connect the TCP socket*/ sock=tcp_connect(host,port); /* Connect the SSL socket */ ssl=SSL_new(ctx); sbio=BIO_new_sock

  • How do you do timed-out persistent/keep alive SSL connections with blocking sockets? 2011-07-11

    A previous question asked if changing one line of code implemented persistent SSL connections. After seeing that question's responses, and checking the dearth of SSL documentation, the following appear true: for the server, a persistent connection is

Copyright (C), All Rights Reserved.

processed in 0.780 (s). 13 q(s)