Skip to content

class_gsm_secure_context

Sara Damiano edited this page Oct 19, 2026 · 1 revision

title: "GsmSecureContext" description: "Modem-owned SSL context configuration with application-owned storage." id: "class_gsm_secure_context" kind: "class" project: "TinyGSM" version: "0.12.0" source_file: "src/TinyGsmSSL.tpp" source_line: 561 generated_at: "2026-10-19"

GsmSecureContext (class)

Module: GsmSecureContext Modem-owned SSL context configuration with application-owned storage.

A context registers itself with one hardware SSL context slot in a modem. The application must keep the context alive while any secure client may use its index. The modem must outlive every context and client attached to it. Copying is disabled because each registered object has unique ownership of its registry slot.

#include <src/TinyGsmSSL.tpp>

Secure context constructors and initialization

Name
GsmSecureContext()
Create an unattached SSL context with default settings.
GsmSecureContext(modemType & modem, uint8_t contextIndex = 0)
Create and attach an SSL context to a modem context slot.
GsmSecureContext(modemType & modem, SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, const char * CAcertName = nullptr, const char * clientCertName = nullptr, const char * clientKeyName = nullptr)
Create an SSL context with certificate authentication settings.
GsmSecureContext(modemType & modem, uint8_t contextIndex, SSLAuthMode sslAuthMode, SSLVersion sslVersion = SSLVersion::TLS1_2, const char * CAcertName = nullptr, const char * clientCertName = nullptr, const char * clientKeyName = nullptr)
Create an SSL context with certificate authentication and explicit context index.
GsmSecureContext(modemType & modem, const char * pskIdent, const char * psKey, SSLVersion sslVersion = SSLVersion::TLS1_2)
Create an SSL context with pre-shared key (PSK) settings.
GsmSecureContext(modemType & modem, uint8_t contextIndex, const char * pskIdent, const char * psKey, SSLVersion sslVersion = SSLVersion::TLS1_2)
Create an SSL context with PSK and explicit context index.
GsmSecureContext(modemType & modem, const char * pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2)
Create an SSL context with PSK table name.
GsmSecureContext(modemType & modem, uint8_t contextIndex, const char * pskTableName, SSLVersion sslVersion = SSLVersion::TLS1_2)
Create an SSL context with PSK table and explicit context index.
~GsmSecureContext()
Unregister this context from its modem.
bool init(modemType * modem, uint8_t contextIndex = 0)
Attach or reattach this object to a modem SSL context slot.

Secure context configuration functions

Name
void setSSLAuthMode(SSLAuthMode mode)
Set the SSL authentication mode.
void setSSLVersion(SSLVersion version)
Set the SSL/TLS protocol version.

Secure context certificate assignment functions

Name
void setCACertName(const char * CAcertName)
Set or clear the CA certificate file name.
void setCACertName(const String & CAcertName)
Set or clear the CA certificate file name.
void setClientCredentials(const char * clientCertName, const char * clientKeyName)
Set or clear the client certificate and private key.
void setClientCredentials(const String & clientCertName, const String & clientKeyName)
Set or clear the client certificate and private key.

Secure context PSK assignment functions

Name
void setPSKTableName(const char * pskTableName)
Set or clear the PSK table file name.
void setPSKTableName(const String & pskTableName)
Set or clear the PSK table file name.
void setPreSharedKey(const char * pskIdent, const char * psKey)
Set or clear a pre-shared key identity and key.
void setPreSharedKey(const String & pskIdent, const String & psKey)
Set or clear a pre-shared key identity and key.

Public Functions

Name
bool isAttached()
Check whether this context is registered with a modem.
uint8_t getSSLContextIndex()
Get the hardware SSL context index.

Public Functions Documentation

function isAttached()

​

bool isAttached()
  • Return: true when attached; otherwise false.

function getSSLContextIndex()

​

uint8_t getSSLContextIndex()

Public Functions Documentation

Secure context constructors and initialization

function GsmSecureContext()

​

 GsmSecureContext()

function GsmSecureContext(modemType &, uint8_t)

​

 GsmSecureContext(modemType & modem, uint8_t contextIndex = 0)

Use isAttached() to determine whether registration succeeded.

  • Parameters:
    • modem The modem that owns the hardware SSL context.
    • contextIndex The zero-based hardware SSL context index.

function GsmSecureContext(modemType &, SSLAuthMode, SSLVersion, const char *, const char *, const char *)

​

explicit  GsmSecureContext(modemType & modem, SSLAuthMode sslAuthMode, SSLVersion sslVersion = <a href="_tiny_gsm_s_s_l_8tpp.html#a4cec5319261492fb0afbc8c3aded7055a856386e3fab2cb40740622b380459862" class="m-doc">SSLVersion::<wbr />TLS1_2</a>, const char * CAcertName = nullptr, const char * clientCertName = nullptr, const char * clientKeyName = nullptr)
  • Parameters:
    • modem The modem that owns the SSL contexts
    • sslAuthMode The SSL authentication mode
    • sslVersion The SSL/TLS version (default: TLS1_2)
    • CAcertName The name of the CA certificate file
    • clientCertName The name of the client certificate file
    • clientKeyName The name of the client key file

function GsmSecureContext(modemType &, uint8_t, SSLAuthMode, SSLVersion, const char *, const char *, const char *)

​

explicit  GsmSecureContext(modemType & modem, uint8_t contextIndex, SSLAuthMode sslAuthMode, SSLVersion sslVersion = <a href="_tiny_gsm_s_s_l_8tpp.html#a4cec5319261492fb0afbc8c3aded7055a856386e3fab2cb40740622b380459862" class="m-doc">SSLVersion::<wbr />TLS1_2</a>, const char * CAcertName = nullptr, const char * clientCertName = nullptr, const char * clientKeyName = nullptr)
  • Parameters:
    • modem The modem that owns the SSL contexts
    • contextIndex The SSL context index
    • sslAuthMode The SSL authentication mode
    • sslVersion The SSL/TLS version (default: TLS1_2)
    • CAcertName The name of the CA certificate file
    • clientCertName The name of the client certificate file
    • clientKeyName The name of the client key file

function GsmSecureContext(modemType &, const char *, const char *, SSLVersion)

​

explicit  GsmSecureContext(modemType & modem, const char * pskIdent, const char * psKey, SSLVersion sslVersion = <a href="_tiny_gsm_s_s_l_8tpp.html#a4cec5319261492fb0afbc8c3aded7055a856386e3fab2cb40740622b380459862" class="m-doc">SSLVersion::<wbr />TLS1_2</a>)
  • Parameters:
    • modem The modem that owns the SSL contexts
    • pskIdent The PSK identity/hint
    • psKey The pre-shared key
    • sslVersion The SSL/TLS version (default: TLS1_2)

function GsmSecureContext(modemType &, uint8_t, const char *, const char *, SSLVersion)

​

explicit  GsmSecureContext(modemType & modem, uint8_t contextIndex, const char * pskIdent, const char * psKey, SSLVersion sslVersion = <a href="_tiny_gsm_s_s_l_8tpp.html#a4cec5319261492fb0afbc8c3aded7055a856386e3fab2cb40740622b380459862" class="m-doc">SSLVersion::<wbr />TLS1_2</a>)
  • Parameters:
    • modem The modem that owns the SSL contexts
    • contextIndex The SSL context index
    • pskIdent The PSK identity/hint
    • psKey The pre-shared key
    • sslVersion The SSL/TLS version (default: TLS1_2)

function GsmSecureContext(modemType &, const char *, SSLVersion)

​

explicit  GsmSecureContext(modemType & modem, const char * pskTableName, SSLVersion sslVersion = <a href="_tiny_gsm_s_s_l_8tpp.html#a4cec5319261492fb0afbc8c3aded7055a856386e3fab2cb40740622b380459862" class="m-doc">SSLVersion::<wbr />TLS1_2</a>)
  • Parameters:
    • modem The modem that owns the SSL contexts
    • pskTableName The name of the PSK table file
    • sslVersion The SSL/TLS version (default: TLS1_2)

function GsmSecureContext(modemType &, uint8_t, const char *, SSLVersion)

​

explicit  GsmSecureContext(modemType & modem, uint8_t contextIndex, const char * pskTableName, SSLVersion sslVersion = <a href="_tiny_gsm_s_s_l_8tpp.html#a4cec5319261492fb0afbc8c3aded7055a856386e3fab2cb40740622b380459862" class="m-doc">SSLVersion::<wbr />TLS1_2</a>)
  • Parameters:
    • modem The modem that owns the SSL contexts
    • contextIndex The SSL context index
    • pskTableName The name of the PSK table file
    • sslVersion The SSL/TLS version (default: TLS1_2)

function ~GsmSecureContext()

​

 ~GsmSecureContext()

function init(modemType *, uint8_t)

​

bool init(modemType * modem, uint8_t contextIndex = 0)

Reattaching to the same modem and slot succeeds. An invalid index, null modem, or slot registered to another context is rejected without changing the current attachment. When changing slots, the old slot is detached only after the requested slot has been validated.

  • Parameters:
    • modem The modem that owns the hardware SSL context.
    • contextIndex The zero-based hardware SSL context index.
  • Return: true if this object is registered in the requested slot; otherwise false.

Secure context configuration functions

function setSSLAuthMode(SSLAuthMode)

​

void setSSLAuthMode(SSLAuthMode mode)
  • Parameters:
    • mode The SSL authentication mode.

function setSSLVersion(SSLVersion)

​

void setSSLVersion(SSLVersion version)
  • Parameters:
    • version The SSL/TLS protocol version.

Secure context certificate assignment functions

function setCACertName(const char *)

​

void setCACertName(const char * CAcertName)
  • Parameters:
    • CAcertName The CA certificate file name, or nullptr to clear it.

function setCACertName(const String &)

​

void setCACertName(const String & CAcertName)
  • Parameters:
    • CAcertName The CA certificate file name, or nullptr to clear it.

function setClientCredentials(const char *, const char *)

​

void setClientCredentials(const char * clientCertName, const char * clientKeyName)

Both names are stored only when both are non-null and non-empty. Otherwise both stored names are cleared.

  • Parameters:
    • clientCertName The client certificate file name.
    • clientKeyName The matching private-key file name.

function setClientCredentials(const String &, const String &)

​

void setClientCredentials(const String & clientCertName, const String & clientKeyName)

Both names are stored only when both are non-null and non-empty. Otherwise both stored names are cleared.

  • Parameters:
    • clientCertName The client certificate file name.
    • clientKeyName The matching private-key file name.

Secure context PSK assignment functions

function setPSKTableName(const char *)

​

void setPSKTableName(const char * pskTableName)
  • Parameters:
    • pskTableName The PSK table file name, or nullptr to clear it.

function setPSKTableName(const String &)

​

void setPSKTableName(const String & pskTableName)
  • Parameters:
    • pskTableName The PSK table file name, or nullptr to clear it.

function setPreSharedKey(const char *, const char *)

​

void setPreSharedKey(const char * pskIdent, const char * psKey)

Both values are stored only when both are non-null and non-empty. Otherwise both stored values are cleared.

  • Parameters:
    • pskIdent The pre-shared key identity.
    • psKey The pre-shared key.

function setPreSharedKey(const String &, const String &)

​

void setPreSharedKey(const String & pskIdent, const String & psKey)

Both values are stored only when both are non-null and non-empty. Otherwise both stored values are cleared.

  • Parameters:
    • pskIdent The pre-shared key identity.
    • psKey The pre-shared key.

Generated by Doxygen and m.css with templates from doxybook2

Clone this wiki locally