typedef char*(* MyQttTlsCertificateFileLocator)(MyQttCtx *ctx, MyQttConn *connection, const char *serverName, axlPointer user_data)

Handler definition for those functions that allows to locate the certificate file to be used while enabling TLS support.

Once a TLS negotiation is started at least two files are required to enable TLS cyphering: the certificate and the private key. Two handlers are used by MyQtt to allow user app level to configure file locations for both files.

This handler is used to configure location for the certificate file. The function will receive the connection where the TLS is being request to be activated and the serverName value which hold a optional host name value requesting to act as the server configured by this value if SNI indication is received.

The function must return a path to the certificate using a dynamically allocated value or the content of the certificate itself. Once finished, MyQtt will unref it.

The function should return a basename file avoiding full path file names. This is because the MyQtt will use myqtt_support_find_data_file function to locate the file provided. That function is configured to lookup on the configured search path provided by myqtt_support_add_search_path or myqtt_support_add_search_path_ref.

As a consequence:

  • If all certificate files are located at /etc/repository/certificates and the serverName.cert is to be used DO NOT return on this function /etc/repository/certificates/serverName.cert
  • Instead, configure /etc/repository/certificates at myqtt_support_add_search_path and return servername.cert.
  • Doing previous practice will allow your code to be as platform/directory-structure independent as possible. The same function works on every installation, the only question to be configured are the search paths to lookup.
ctxThe context where the operation is taking place.
connectionThe connection where the TLS negotiation was received.
serverNameAn optional value requesting to act as the server serverName. This value is supposed to be used to select the right certificate file (according to the common value stored on it).
user_dataOptional reference to user data configured at myqtt_tls_listener_set_certificate_handlers
A newly allocated value containing the path to the certificate file or the certificate content to be used.