08-28-2024, 01:50 PM
(This post was last modified: 08-28-2024, 01:52 PM by 3ddark.
Edit Reason: note
)
I want to make a TCP Socket application that is secured with simple self signed SSL certificates.
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.
I am writing the operations I have done step by step. Please tell me where I am missing or making a mistake.
I have attached the project files. If you could please tell me what the problem is, I would be very grateful.
I used the files in step 1 to create the certificate and as dll.
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.
I am writing the operations I have done step by step. Please tell me where I am missing or making a mistake.
- I downloaded the openssl-1.0.2u-i386-win32.zip package from the address below.
https://github.com/IndySockets/OpenSSL-Binaries
- I created my self-signed certificates with the following steps.
- 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.