Update sample to utilize SSL error callback function

Signed-off-by: tbeu <tc@tbeu.de>
This commit is contained in:
tbeu 2018-08-22 09:09:30 +02:00
parent 98cd807b63
commit 7a43da5ca1
1 changed files with 9 additions and 0 deletions

View File

@ -206,6 +206,13 @@ void onPublish(void* context, MQTTAsync_successData* response)
}
static int onSSLError(const char *str, size_t len, void *context)
{
MQTTAsync client = (MQTTAsync)context;
return fprintf(stderr, "SSL error: %s\n", str);
}
void myconnect(MQTTAsync client)
{
MQTTAsync_connectOptions conn_opts = MQTTAsync_connectOptions_initializer;
@ -256,6 +263,8 @@ void myconnect(MQTTAsync client)
ssl_opts.privateKey = opts.key;
ssl_opts.privateKeyPassword = opts.keypass;
ssl_opts.enabledCipherSuites = opts.ciphers;
ssl_opts.ssl_error_cb = onSSLError;
ssl_opts.ssl_error_context = client;
conn_opts.ssl = &ssl_opts;
}