UnknownUsr
UnknownUsr

Reputation: 43

C++Builder XE Raw SSL socket

I need to connect to a server with SSL in C++Builder XE7. I can find stuff for HTTPS and SMTP but nothing for custom connections. In BCB5 it was a lot easier, I would do it with custom code but now with Android and iOS, things need to be done a little differently as we now need to support these products too.

I've looked at TIdSocketSSL but with the very few examples I could find, it seems to need an owner which ultimate comes from SMTP or HTTPS.

Upvotes: 2

Views: 682

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597215

C++Builder ships with Indy, which has a TIdTCPClient component that you can use for implementing custom protocols. There are plenty of examples on Embarcadero's forum, Indy's forum, StackOverflow, and various blogs demonstrating how to send/receive custom data with Indy.

For SSL/TLS, simply assign a TIdSSLIOHandlerSocketOpenSSL component to the TIdTCPClient::IOHandler property before calling Connect(), and configure its properties as needed (certificates, SSL/TLS version(s), etc). When you want to perform the SSL handshake, set the TIdSSLIOHandlerOpenSSL::PassThrough property to false. You can set it before calling Connect() so the handshake is immediate before any data is exchanged (aka implicit SSL/TLS), or you can set it after exchanging unencrypted data first (aka explicit SSL/TLS), depending on your protocol needs.

Upvotes: 2

Related Questions