.tlsinit Method


For the currently selected socket (selection is made through sock.num), initializes all resources required for establishing a TLS connection.


sock.tlsinit(offset as dword) as enum


0 — PL_TLS_SUCCESS — Initialization was completed successfully

1 — PL_TLS_REJECTED — Initialization attempt was rejected

2 — PL_TLS_ERROR_IN_USE — TLS is already in use on another socket

3 — PL_TLS_ERROR_CERT — Certificate error

4 — PL_TLS_ERROR_NO_BUFF — Insufficient memory

5 — PL_TLS_ERROR_INTERNAL — Unspecified internal error

See Also:

Transport Layer Security (TLS), Establishing a Secure Connection, Obtaining Encryption Certificate




Offset of the certificate file included in the compiled binary of your project. The offset is obtained by using the romfile.offset read-only property.


This method initializes the certificate authority (CA) — based on the certificate included in the project as a resource file — and the TLS context for the selected socket. If 0 is passed as the value of offset, sock.tlsinit will skip the verification of the certificate.

If sock.tlsinit is called after TLS has already been initialized on the current socket (sock.tlscurrentnum = sock.num), it will return PL_TLS_REJECTED. If called after TLS has already been initialized on a different socket ( sock.num <> sock.tlscurrentnum), it will return PL_TLS_ERROR_IN_USE.

PL_TLS_ERROR_CERT will be returned if the certificate can't be parsed because it is not an X.509 certificate or because is uses an unsupported cypher suite.

On TPP2(G2), TPP3(G2), EM2000, and EM2001 platforms, PL_TLS_ERROR_NO_BUFF will be returned if your code does not allocate the required number of buffer pages via the sock.tlsbuffrq method.

Contact Tibbo support if you ever see the PL_TLS_ERROR_INTERNAL error.