TrustCore SDK NanoSSL API reference  version 7.0
Core (Async and Sync) Client and Server Callbacks

Customizable NanoSSL asynchronous and synchronous, server and client callbacks. More...

Variables

sbyte4(* sslSettings::funcPtrAlertCallback )(sbyte4 connectionInstance, sbyte4 alertId, sbyte4 alertClass)
 Do application-specific work required when the alert is received. More...
 
sbyte4(* sslSettings::funcPtrNewHandshakeCallback )(sbyte4 connectionInstance, sbyte4 *pRetDoRehandshake, sbyte4 *pRetDoSessionResumption)
 Determine whether to grant or ignore a client or server rehandshake request. More...
 

Detailed Description

The following callbacks can be customized for your application:

Variable Documentation

◆ funcPtrAlertCallback

sbyte4(* sslSettings::funcPtrAlertCallback) (sbyte4 connectionInstance, sbyte4 alertId, sbyte4 alertClass)

This callback function does any application-specific work required when the alert is received.

For example, a typical response upon receiving an SSL_ALERT_ACCESS_DENIED error would be to notify the client application that this error has occurred.

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
1.41
Version
1.41 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_ALERTS__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_CLIENT__
  • __ENABLE_MOCANA_SSL_ASYNC_CLIENT_API__
  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
alertIdSSL alert code (see ssl_alert_codes).
alertClassAlert class (SSLALERTLEVEL_WARNING or SSLALERTLEVEL_FATAL).
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function for your application if SSL is configured to use alerts.

ssl.h

◆ funcPtrNewHandshakeCallback

sbyte4(* sslSettings::funcPtrNewHandshakeCallback) (sbyte4 connectionInstance, sbyte4 *pRetDoRehandshake, sbyte4 *pRetDoSessionResumption)

This callback function determines whether to grant or ignore a client or server rehandshake rehandshake request. For example, this callback could count the number of rehandshake requests received, and choose to ignore the request after an excessive number of attempts (which could indicate a DoS attack).

Callback registration happens at session creation and initialization by assigning your custom callback function (which can have any name) to this callback pointer.

Since
2.45
Version
2.45 and later

To enable this callback, the following flag must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_NEW_HANDSHAKE__

Additionally, at least one of the following flags must be defined in moptions.h:

  • __ENABLE_MOCANA_SSL_CLIENT__
  • __ENABLE_MOCANA_SSL_ASYNC_CLIENT_API__
  • __ENABLE_MOCANA_SSL_SERVER__
  • __ENABLE_MOCANA_SSL_ASYNC_SERVER_API__
Parameters
connectionInstancePointer to the SSL/TLS Client instance.
pRetDoRehandshakeOn return, pointer to TRUE if request should be granted; otherwise, pointer to FALSE.
pRetDoSessionResumptionOn return, pointer to TRUE if request should be granted; otherwise, pointer to FALSE.
Returns
OK (0) if successful; otherwise a negative number error code definition from merrors.h. To retrieve a string containing an English text error identifier corresponding to the function's returned error status, use the DISPLAY_ERROR macro.
Remarks
You should define and customize this hookup function if the server should respond in some fashion to a client's rehandshake request.

ssl.h