Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SSL TcpServer, TcpClient
#1
Exclamation I want to make a TCP Socket application that is secured with simple self signed SSL certificates. Exclamation

In fact, IndyTCPServer and IndyTcpClient allow me to do most of the operations very easily.
However, when it comes to SSL operations, I fail.

I really don't understand why I can't do this. There are many examples, blogs and videos. But it shouldn't be this hard.
I have easily done a similar SSL operation for Mosquitto Broker on Linux. Angry

I am writing the operations I have done step by step. Please tell me where I am missing or making a mistake.

  1. I downloaded the openssl-1.0.2u-i386-win32.zip package from the address below.
    https://github.com/IndySockets/OpenSSL-Binaries
  2. I created my self-signed certificates with the following steps.
  3. I have made SSL settings. As seen in the screenshot, I am establishing a connection with the Server.
        Then I get an error in the Connect process with the Client. When I look at it with Debug, the first error that appears is,    "Error accepting connection with SSL."then the error I see on the screen is    "Connection reset by peer."
Code:
## SERVER ##
openssl genpkey -algorithm RSA -out server.key -aes256
  Enter PEM pass phrase: 123456
openssl req -new -key server.key -out server.csr
  Validate pass: 123456
    Country: TR
    State: Blank
    Locality: Blank
    Organization Name: Acme Ltd
    Organization Unit: IT
    Common Name: 127.0.0.1
    Email: Blank
    Extra Attributes: Blank
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
  Validate pass: 123456


## CLIENT ##
openssl genpkey -algorithm RSA -out client.key -aes256
  Enter PEM pass phrase: 123456
openssl req -new -key client.key -out client.csr
  Validate pass: 123456
openssl req -new -key server.key -out server.csr
  Validate pass: 123456
    Country: TR
    State: Blank
    Locality: Blank
    Organization Name: Acme Ltd
    Organization Unit: IT
    Common Name: 127.0.0.1
    Email: Blank
    Extra Attributes: Blank
openssl x509 -req -days 365 -in client.csr -signkey client.key -out client.crt
  Validate pass: 123456

I have attached the project files. If you could please tell me what the problem is, I would be very grateful.


Code:
procedure TfrmMain.IdTCPServer1Connect(AContext: TIdContext);
begin
  if AContext.Connection.IOHandler is TIdSSLIOHandlerSocketBase then
    TIdSSLIOHandlerSocketBase(AContext.Connection.IOHandler).PassThrough := False;
  mmoSrv.Lines.Add('Connected');
end;

procedure TfrmMain.IdServerIOHandlerSSLOpenSSL1GetPassword(var Password: string);
begin
  Password := '123456';
end;

procedure TfrmMain.IdSSLIOHandlerSocketOpenSSL1GetPassword(var Password: string);
begin
  Password := '123456';
end;

I used the files in step 1 to create the certificate and as dll.


Attached Files
.zip   clienttest.zip (Size: 58.99 KB / Downloads: 2)
Reply


Messages In This Thread
SSL TcpServer, TcpClient - by 3ddark - 08-28-2024, 01:50 PM
RE: SSL TcpServer, TcpClient - by rlebeau - 08-28-2024, 04:15 PM
RE: SSL TcpServer, TcpClient - by 3ddark - 08-28-2024, 05:08 PM
RE: SSL TcpServer, TcpClient - by rlebeau - 08-28-2024, 05:52 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)