Delphi TLS 1.3 Without OpenSSL DLLs

· Components
Delphi TLS 1.3 Without OpenSSL DLLs

Every Delphi developer who has shipped TLS knows the routine. Which OpenSSL version does this machine have. Why does the customer's server have 1.1 and the build box have 3.0. Which two DLLs go next to the executable, and what happens when an antivirus removes one of them. sgcWebSockets 2026.10 adds a way out: a TLS 1.3 engine written in Object Pascal, inside the library, with no DLL of any kind.

It is a real implementation, not a wrapper: the handshake, the record layer, the key schedule and the certificate validation are all Pascal. A client or a server speaks TLS with nothing installed.

One Property

oClient := TsgcWebSocketClient.Create(nil);
oClient.URL := 'wss://www.esegece.com:2053';
oClient.TLSOptions.IOHandler := iohNativeTLS;
oClient.Active := True;

On a server it is the same switch on SSLOptions:

oServer.SSLOptions.IOHandler := iohNativeTLS;
oServer.SSLOptions.CertFile := 'server.pem';
oServer.SSLOptions.KeyFile := 'server.key';
oServer.SSL := True;

ALPN, S N I and client certificates are there, on the Indy handler and on the I O C P and E P O L L servers. Nothing else about your code changes.

Trusting What the Machine Already Trusts

A TLS client is only as good as its trust anchors, and shipping a cacert.pem that ages badly is its own maintenance problem. The engine can use the roots the operating system already trusts:

oClient.TLSOptions.NativeTLS_Options.UseSystemRoots := True;

On Windows they come from the ROOT system store, on Linux and Android from the first certificate bundle found among the usual locations. It is off by default, which keeps the trust anchors exactly what RootCertFile says.

Post-Quantum, Today, Because of Tomorrow

An attacker who cannot break your TLS session today can still record it and keep it. The interesting question is not whether a quantum computer exists now, it is how long your traffic stays sensitive. That is why TLS is moving to hybrid key exchange, where the shared secret is safe as long as either half holds.

The engine negotiates the hybrid groups of RFC 10024, and the default group list already starts with the hybrid one:

oClient.TLSOptions.NativeTLS_Options.Groups :=
  'X25519MLKEM768:SecP256r1MLKEM768:X25519';

The three hybrids are X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024. Both lists take OpenSSL style names separated by colons, and an empty value keeps the engine defaults.

The Cryptography Under It

The same release adds the post-quantum primitives themselves to the sgcCrypto pack, in Object Pascal, with no external library:

They are validated against the NIST known answer vectors, which ship with the library as a test set rather than as a claim.

Hardening You Do Not Have to Ask For

The same pass hardened the classical side against timing attacks. RSA private key operations use blinding and a constant time exponentiation with a check of the result, elliptic curve scalar multiplication and Ed25519 signing run in constant time, and AES and GHASH no longer index a table with secret bytes. Private keys are checked when they are imported, so a key that does not belong to its certificate is refused instead of producing signatures nobody can verify, and a signature whose ASN.1 encoding is not minimal DER is now rejected rather than accepted.

When to Use Which

OpenSSL and SChannel are not going anywhere, and for a lot of applications they remain the right answer: OpenSSL if you need TLS 1.2 interoperability with something old, SChannel if the customer's policy is that Windows owns the cryptography. The native engine is for the case where the deployment is the problem: a single executable, no DLL beside it, the same behaviour on Windows and on Linux, and post-quantum key exchange without waiting for the platform to catch up.

Upgrading

The engine is part of the sgcCrypto pack and is selected per component, so nothing changes until you set IOHandler. A build without the crypto units raises a clear message instead of failing obscurely at the handshake.

Watch It

There is a short video of this on the eSeGeCe channel.

Questions, feedback or migration help? Get in touch — you will get a reply from the people who wrote the code.