42 #include <openssl/ssl.h> 43 #include <openssl/err.h> 44 #include <openssl/crypto.h> 45 #include <openssl/x509v3.h> 49 static int SSLSocket_error(
char* aString, SSL* ssl,
int sock,
int rc,
int (*cb)(
const char *str,
size_t len,
void *u),
void* u);
50 char* SSL_get_verify_result_string(
int rc);
51 void SSL_CTX_info_callback(
const SSL* ssl,
int where,
int ret);
52 char* SSLSocket_get_version_string(
int version);
53 void SSL_CTX_msg_callback(
57 const void* buf,
size_t len,
59 int pem_passwd_cb(
char* buf,
int size,
int rwflag,
void*
userdata);
64 #if (OPENSSL_VERSION_NUMBER >= 0x010000000) 65 extern void SSLThread_id(CRYPTO_THREADID *
id);
67 extern unsigned long SSLThread_id(
void);
69 extern void SSLLocks_callback(
int mode,
int n,
const char *file,
int line);
72 void SSLSocket_addPendingRead(
int sock);
75 static int handle_openssl_init = 1;
80 static int tls_ex_index_ssl_opts;
82 #if defined(_WIN32) || defined(_WIN64) 96 static int SSLSocket_error(
char* aString, SSL* ssl,
int sock,
int rc,
int (*cb)(
const char *str,
size_t len,
void *u),
void* u)
102 error = SSL_get_error(ssl, rc);
104 error = ERR_get_error();
105 if (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)
107 Log(
TRACE_MIN, -1,
"SSLSocket error WANT_READ/WANT_WRITE");
111 static char buf[120];
113 if (strcmp(aString,
"shutdown") != 0)
114 Log(
TRACE_MIN, -1,
"SSLSocket error %s(%d) in %s for socket %d rc %d errno %d %s\n", buf, error, aString, sock, rc, errno, strerror(errno));
116 ERR_print_errors_cb(cb, u);
117 if (error == SSL_ERROR_SSL || error == SSL_ERROR_SYSCALL)
129 X509_message_table[] =
131 { X509_V_OK,
"X509_V_OK" },
132 { X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT,
"X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT" },
133 { X509_V_ERR_UNABLE_TO_GET_CRL,
"X509_V_ERR_UNABLE_TO_GET_CRL" },
134 { X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE,
"X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE" },
135 { X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE,
"X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE" },
136 { X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY,
"X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY" },
137 { X509_V_ERR_CERT_SIGNATURE_FAILURE,
"X509_V_ERR_CERT_SIGNATURE_FAILURE" },
138 { X509_V_ERR_CRL_SIGNATURE_FAILURE,
"X509_V_ERR_CRL_SIGNATURE_FAILURE" },
139 { X509_V_ERR_CERT_NOT_YET_VALID,
"X509_V_ERR_CERT_NOT_YET_VALID" },
140 { X509_V_ERR_CERT_HAS_EXPIRED,
"X509_V_ERR_CERT_HAS_EXPIRED" },
141 { X509_V_ERR_CRL_NOT_YET_VALID,
"X509_V_ERR_CRL_NOT_YET_VALID" },
142 { X509_V_ERR_CRL_HAS_EXPIRED,
"X509_V_ERR_CRL_HAS_EXPIRED" },
143 { X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD,
"X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD" },
144 { X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD,
"X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD" },
145 { X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD,
"X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD" },
146 { X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD,
"X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD" },
147 { X509_V_ERR_OUT_OF_MEM,
"X509_V_ERR_OUT_OF_MEM" },
148 { X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT,
"X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT" },
149 { X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN,
"X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN" },
150 { X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY,
"X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY" },
151 { X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE,
"X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE" },
152 { X509_V_ERR_CERT_CHAIN_TOO_LONG,
"X509_V_ERR_CERT_CHAIN_TOO_LONG" },
153 { X509_V_ERR_CERT_REVOKED,
"X509_V_ERR_CERT_REVOKED" },
154 { X509_V_ERR_INVALID_CA,
"X509_V_ERR_INVALID_CA" },
155 { X509_V_ERR_PATH_LENGTH_EXCEEDED,
"X509_V_ERR_PATH_LENGTH_EXCEEDED" },
156 { X509_V_ERR_INVALID_PURPOSE,
"X509_V_ERR_INVALID_PURPOSE" },
157 { X509_V_ERR_CERT_UNTRUSTED,
"X509_V_ERR_CERT_UNTRUSTED" },
158 { X509_V_ERR_CERT_REJECTED,
"X509_V_ERR_CERT_REJECTED" },
159 { X509_V_ERR_SUBJECT_ISSUER_MISMATCH,
"X509_V_ERR_SUBJECT_ISSUER_MISMATCH" },
160 { X509_V_ERR_AKID_SKID_MISMATCH,
"X509_V_ERR_AKID_SKID_MISMATCH" },
161 { X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH,
"X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH" },
162 { X509_V_ERR_KEYUSAGE_NO_CERTSIGN,
"X509_V_ERR_KEYUSAGE_NO_CERTSIGN" },
163 { X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER,
"X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER" },
164 { X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION,
"X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION" },
165 { X509_V_ERR_KEYUSAGE_NO_CRL_SIGN,
"X509_V_ERR_KEYUSAGE_NO_CRL_SIGN" },
166 { X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION,
"X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION" },
167 { X509_V_ERR_INVALID_NON_CA,
"X509_V_ERR_INVALID_NON_CA" },
168 { X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED,
"X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED" },
169 { X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE,
"X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE" },
170 { X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED,
"X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED" },
171 { X509_V_ERR_INVALID_EXTENSION,
"X509_V_ERR_INVALID_EXTENSION" },
172 { X509_V_ERR_INVALID_POLICY_EXTENSION,
"X509_V_ERR_INVALID_POLICY_EXTENSION" },
173 { X509_V_ERR_NO_EXPLICIT_POLICY,
"X509_V_ERR_NO_EXPLICIT_POLICY" },
174 { X509_V_ERR_UNNESTED_RESOURCE,
"X509_V_ERR_UNNESTED_RESOURCE" },
175 #if defined(X509_V_ERR_DIFFERENT_CRL_SCOPE) 176 { X509_V_ERR_DIFFERENT_CRL_SCOPE,
"X509_V_ERR_DIFFERENT_CRL_SCOPE" },
177 { X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE,
"X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE" },
178 { X509_V_ERR_PERMITTED_VIOLATION,
"X509_V_ERR_PERMITTED_VIOLATION" },
179 { X509_V_ERR_EXCLUDED_VIOLATION,
"X509_V_ERR_EXCLUDED_VIOLATION" },
180 { X509_V_ERR_SUBTREE_MINMAX,
"X509_V_ERR_SUBTREE_MINMAX" },
181 { X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE,
"X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE" },
182 { X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX,
"X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX" },
183 { X509_V_ERR_UNSUPPORTED_NAME_SYNTAX,
"X509_V_ERR_UNSUPPORTED_NAME_SYNTAX" },
187 #if !defined(ARRAY_SIZE) 191 #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) 194 char* SSL_get_verify_result_string(
int rc)
197 char* retstring =
"undef";
199 for (i = 0; i <
ARRAY_SIZE(X509_message_table); ++i)
201 if (X509_message_table[i].code == rc)
203 retstring = X509_message_table[i].string;
211 void SSL_CTX_info_callback(
const SSL* ssl,
int where,
int ret)
213 if (where & SSL_CB_LOOP)
216 (where & SSL_ST_CONNECT) ?
"connect" : (where & SSL_ST_ACCEPT) ?
"accept" :
"undef",
217 SSL_state_string_long(ssl), SSL_get_cipher_name(ssl));
219 else if (where & SSL_CB_EXIT)
222 (where & SSL_ST_CONNECT) ?
"connect" : (where & SSL_ST_ACCEPT) ?
"accept" :
"undef",
223 SSL_state_string_long(ssl));
225 else if (where & SSL_CB_ALERT)
228 (where & SSL_CB_READ) ?
"read" :
"write",
229 SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret));
231 else if (where & SSL_CB_HANDSHAKE_START)
234 (where & SSL_CB_READ) ?
"read" :
"write",
235 SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret));
237 else if (where & SSL_CB_HANDSHAKE_DONE)
240 (where & SSL_CB_READ) ?
"read" :
"write",
241 SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret));
243 SSL_get_verify_result_string(SSL_get_verify_result(ssl)));
248 SSL_alert_type_string_long(ret), SSL_alert_desc_string_long(ret));
253 char* SSLSocket_get_version_string(
int version)
257 char* retstring = NULL;
263 version_string_table[] =
265 { SSL2_VERSION,
"SSL 2.0" },
266 { SSL3_VERSION,
"SSL 3.0" },
267 { TLS1_VERSION,
"TLS 1.0" },
268 #if defined(TLS2_VERSION) 269 { TLS2_VERSION,
"TLS 1.1" },
271 #if defined(TLS3_VERSION) 272 { TLS3_VERSION,
"TLS 1.2" },
276 for (i = 0; i <
ARRAY_SIZE(version_string_table); ++i)
278 if (version_string_table[i].code == version)
280 retstring = version_string_table[i].string;
285 if (retstring == NULL)
287 sprintf(buf,
"%i", version);
294 void SSL_CTX_msg_callback(
int write_p,
int version,
int content_type,
const void* buf,
size_t len,
321 Log(
TRACE_MINIMUM, -1,
"%s %s %d buflen %d", (write_p ?
"sent" :
"received"),
322 SSLSocket_get_version_string(version),
323 content_type, (
int)len);
327 int pem_passwd_cb(
char* buf,
int size,
int rwflag,
void*
userdata)
334 strncpy(buf, (
char*)(userdata), size);
336 rc = (int)strlen(buf);
347 #if defined(_WIN32) || defined(_WIN64) 348 *mutex = CreateMutex(NULL, 0, NULL);
350 rc = pthread_mutex_init(mutex, NULL);
361 #if defined(_WIN32) || defined(_WIN64) 362 if (WaitForSingleObject(*mutex, INFINITE) != WAIT_FAILED)
364 if ((rc = pthread_mutex_lock(mutex)) == 0)
376 #if defined(_WIN32) || defined(_WIN64) 377 if (ReleaseMutex(*mutex) != 0)
379 if ((rc = pthread_mutex_unlock(mutex)) == 0)
391 #if defined(_WIN32) || defined(_WIN64) 392 rc = CloseHandle(*mutex);
394 rc = pthread_mutex_destroy(mutex);
402 #if (OPENSSL_VERSION_NUMBER >= 0x010000000) 403 extern void SSLThread_id(CRYPTO_THREADID *
id)
405 #if defined(_WIN32) || defined(_WIN64) 406 CRYPTO_THREADID_set_numeric(
id, (
unsigned long)GetCurrentThreadId());
408 CRYPTO_THREADID_set_numeric(
id, (
unsigned long)pthread_self());
412 extern unsigned long SSLThread_id(
void)
414 #if defined(_WIN32) || defined(_WIN64) 415 return (
unsigned long)GetCurrentThreadId();
417 return (
unsigned long)pthread_self();
422 extern void SSLLocks_callback(
int mode,
int n,
const char *file,
int line)
426 if (mode & CRYPTO_LOCK)
427 SSL_lock_mutex(&sslLocks[n]);
429 SSL_unlock_mutex(&sslLocks[n]);
436 handle_openssl_init = bool_value;
449 if (handle_openssl_init)
451 if ((rc = SSL_library_init()) != 1)
454 ERR_load_crypto_strings();
455 SSL_load_error_strings();
461 OpenSSL_add_all_algorithms();
465 sslLocks =
malloc(lockMemSize);
472 memset(sslLocks, 0, lockMemSize);
474 for (i = 0; i < CRYPTO_num_locks(); i++)
476 SSL_create_mutex(&sslLocks[i]);
479 #if (OPENSSL_VERSION_NUMBER >= 0x010000000) 480 CRYPTO_THREADID_set_callback(SSLThread_id);
482 CRYPTO_set_id_callback(SSLThread_id);
484 CRYPTO_set_locking_callback(SSLLocks_callback);
488 SSL_create_mutex(&sslCoreMutex);
490 tls_ex_index_ssl_opts = SSL_get_ex_new_index(0,
"paho ssl options", NULL, NULL, NULL);
501 if (handle_openssl_init)
505 CRYPTO_set_locking_callback(NULL);
510 for (i = 0; i < CRYPTO_num_locks(); i++)
512 SSL_destroy_mutex(&sslLocks[i]);
518 SSL_destroy_mutex(&sslCoreMutex);
523 static unsigned int call_ssl_psk_cb(SSL *ssl,
const char *hint,
char *identity,
unsigned int max_identity_len,
unsigned char *psk,
unsigned int max_psk_len)
530 SSL_CTX *ctx = SSL_get_SSL_CTX(ssl);
549 if (net->ctx == NULL)
551 #if (OPENSSL_VERSION_NUMBER >= 0x10100000L) 552 net->ctx = SSL_CTX_new(TLS_client_method());
563 net->ctx = SSL_CTX_new(SSLv23_client_method());
565 #if defined(SSL_OP_NO_TLSv1) && !defined(OPENSSL_NO_TLS1) 567 net->ctx = SSL_CTX_new(TLSv1_client_method());
570 #if defined(SSL_OP_NO_TLSv1_1) && !defined(OPENSSL_NO_TLS1) 572 net->ctx = SSL_CTX_new(TLSv1_1_client_method());
575 #if defined(SSL_OP_NO_TLSv1_2) && !defined(OPENSSL_NO_TLS1) 577 net->ctx = SSL_CTX_new(TLSv1_2_client_method());
584 if (net->ctx == NULL)
589 SSLSocket_error(
"SSL_CTX_new", NULL, net->
socket, rc, NULL, NULL);
596 if ((rc = SSL_CTX_use_certificate_chain_file(net->ctx, opts->
keyStore)) != 1)
601 SSLSocket_error(
"SSL_CTX_use_certificate_chain_file", NULL, net->
socket, rc, NULL, NULL);
610 SSL_CTX_set_default_passwd_cb(net->ctx, pem_passwd_cb);
615 rc = SSL_CTX_use_PrivateKey_file(net->ctx, opts->
privateKey, SSL_FILETYPE_PEM);
623 SSLSocket_error(
"SSL_CTX_use_PrivateKey_file", NULL, net->
socket, rc, NULL, NULL);
630 if ((rc = SSL_CTX_load_verify_locations(net->ctx, opts->
trustStore, opts->
CApath)) != 1)
635 SSLSocket_error(
"SSL_CTX_load_verify_locations", NULL, net->
socket, rc, NULL, NULL);
641 if ((rc = SSL_CTX_set_default_verify_paths(net->ctx)) != 1)
646 SSLSocket_error(
"SSL_CTX_set_default_verify_paths", NULL, net->
socket, rc, NULL, NULL);
658 SSLSocket_error(
"SSL_CTX_set_cipher_list", NULL, net->
socket, rc, NULL, NULL);
663 #ifndef OPENSSL_NO_PSK 666 SSL_CTX_set_ex_data(net->ctx, tls_ex_index_ssl_opts, opts);
667 SSL_CTX_set_psk_client_callback(net->ctx, call_ssl_psk_cb);
671 #if (OPENSSL_VERSION_NUMBER >= 0x010002000) 673 if ((rc = SSL_CTX_set_alpn_protos(net->ctx, opts->
protos, opts->
protos_len)) != 0)
678 SSLSocket_error(
"SSL_CTX_set_alpn_protos", NULL, net->
socket, rc, NULL, NULL);
684 SSL_CTX_set_mode(net->ctx, SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER);
688 SSL_CTX_free(net->ctx);
698 const char*
hostname,
size_t hostname_len)
704 if (net->ctx != NULL || (rc = SSLSocket_createContext(net, opts)) == 1)
706 char *hostname_plus_null;
709 SSL_CTX_set_info_callback(net->ctx, SSL_CTX_info_callback);
710 SSL_CTX_set_msg_callback(net->ctx, SSL_CTX_msg_callback);
712 SSL_CTX_set_verify(net->ctx, SSL_VERIFY_PEER, NULL);
714 net->ssl = SSL_new(net->ctx);
719 const char* cipher = SSL_get_cipher_list(net->ssl, i);
724 if ((rc = SSL_set_fd(net->ssl, net->
socket)) != 1) {
728 SSLSocket_error(
"SSL_set_fd", net->ssl, net->
socket, rc, NULL, NULL);
730 hostname_plus_null =
malloc(hostname_len + 1u );
731 if (hostname_plus_null)
733 MQTTStrncpy(hostname_plus_null, hostname, hostname_len + 1u);
734 if ((rc = SSL_set_tlsext_host_name(net->ssl, hostname_plus_null)) != 1) {
738 SSLSocket_error(
"SSL_set_tlsext_host_name", NULL, net->
socket, rc, NULL, NULL);
740 free(hostname_plus_null);
753 int SSLSocket_connect(SSL* ssl,
int sock,
const char* hostname,
int verify,
int (*cb)(
const char *str,
size_t len,
void *u),
void* u)
760 rc = SSL_connect(ssl);
764 error = SSLSocket_error(
"SSL_connect", ssl, sock, rc, cb, u);
767 if (error == SSL_ERROR_WANT_READ || error == SSL_ERROR_WANT_WRITE)
770 #if (OPENSSL_VERSION_NUMBER >= 0x010002000) 773 char* peername = NULL;
777 X509* cert = SSL_get_peer_certificate(ssl);
780 rc = X509_check_host(cert, hostname, hostname_len, 0, &peername);
785 (
int)hostname_len, hostname, rc);
787 if (peername != NULL)
788 OPENSSL_free(peername);
791 if (rc == 0 || rc == -1 || rc == -2)
793 char* ip_addr =
malloc(hostname_len + 1);
797 strncpy(ip_addr, hostname, hostname_len);
798 ip_addr[hostname_len] =
'\0';
800 rc = X509_check_ip_asc(cert, ip_addr, 0);
801 Log(
TRACE_MIN, -1,
"rc from X509_check_ip_asc is %d", rc);
806 if (rc == 0 || rc == -1 || rc == -2)
836 if ((rc = SSL_read(ssl, c, (
size_t)1)) < 0)
838 int err = SSLSocket_error(
"SSL_read - getch", ssl, socket, rc, NULL, NULL);
839 if (err == SSL_ERROR_WANT_READ || err == SSL_ERROR_WANT_WRITE)
881 if ((*rc = SSL_read(ssl, buf + (*actual_len), (
int)(bytes - (*actual_len)))) < 0)
883 *rc = SSLSocket_error(
"SSL_read - getdata", ssl, socket, *rc, NULL, NULL);
884 if (*rc != SSL_ERROR_WANT_READ && *rc != SSL_ERROR_WANT_WRITE)
898 if (*actual_len == bytes)
905 if (SSL_pending(ssl) > 0)
906 SSLSocket_addPendingRead(socket);
911 Log(
TRACE_MAX, -1,
"SSL_read: %lu bytes expected but %lu bytes now received", bytes, *actual_len);
922 SSL_CTX_free(net->ctx);
927 static List pending_reads = {NULL, NULL, NULL, 0, 0};
941 rc = SSL_shutdown(net->ssl);
945 SSLSocket_destroyContext(net);
961 iovec.iov_len = (
ULONG)buf0len;
962 for (i = 0; i < bufs.
count; i++)
965 ptr = iovec.iov_base = (
char *)
malloc(iovec.iov_len);
971 memcpy(ptr, buf0, buf0len);
973 for (i = 0; i < bufs.
count; i++)
982 SSL_lock_mutex(&sslCoreMutex);
984 if ((rc = SSL_write(ssl, iovec.iov_base, iovec.iov_len)) == iovec.iov_len)
988 sslerror = SSLSocket_error(
"SSL_write", ssl, socket, rc, NULL, NULL);
990 if (sslerror == SSL_ERROR_WANT_WRITE)
992 int* sockmem = (
int*)
malloc(
sizeof(
int));
998 SSL_unlock_mutex(&sslCoreMutex);
1001 Log(
TRACE_MIN, -1,
"Partial write: incomplete write of %lu bytes on SSL socket %d",
1002 iovec.iov_len, socket);
1012 SSL_unlock_mutex(&sslCoreMutex);
1015 free(iovec.iov_base);
1020 for (i = 0; i < bufs.
count; ++i)
1035 void SSLSocket_addPendingRead(
int sock)
1040 int* psock = (
int*)
malloc(
sizeof(sock));
1044 ListAppend(&pending_reads, psock,
sizeof(sock));
1048 Log(
TRACE_MIN, -1,
"SSLSocket_addPendingRead: socket %d already in the list", sock);
1058 if (pending_reads.
count > 0)
1073 if ((rc = SSL_write(pw->ssl, pw->
iovecs[0].iov_base, pw->
iovecs[0].iov_len)) == pw->
iovecs[0].iov_len)
1077 Log(
TRACE_MIN, -1,
"SSL continueWrite: partial write now complete for socket %d", pw->
socket);
1082 int sslerror = SSLSocket_error(
"SSL_write", pw->ssl, pw->
socket, rc, NULL, NULL);
1083 if (sslerror == SSL_ERROR_WANT_WRITE)
char * SocketBuffer_getQueuedData(int socket, size_t bytes, size_t *actual_len)
int SSLSocket_getch(SSL *ssl, int socket, char *c)
#define MQTT_SSL_VERSION_DEFAULT
#define MQTT_SSL_VERSION_TLS_1_0
#define MQTT_DEFAULT_PORT
int SSLSocket_setSocketForSSL(networkHandles *net, MQTTClient_SSLOptions *opts, const char *hostname, size_t hostname_len)
#define MQTT_SSL_VERSION_TLS_1_1
#define PAHO_MEMORY_ERROR
void SocketBuffer_queueChar(int socket, char c)
const char * enabledCipherSuites
int SSLSocket_connect(SSL *ssl, int sock, const char *hostname, int verify, int(*cb)(const char *str, size_t len, void *u), void *u)
static l_noret error(LoadState *S, const char *why)
#define MQTT_SSL_VERSION_TLS_1_2
int disableDefaultTrustStore
char * MQTTStrncpy(char *dest, const char *src, size_t dest_size)
void SocketBuffer_interrupted(int socket, size_t actual_len)
unsigned int(* ssl_psk_cb)(const char *hint, char *identity, unsigned int max_identity_len, unsigned char *psk, unsigned int max_psk_len, void *u)
int ListRemoveItem(List *aList, void *content, int(*callback)(void *, void *))
void SSLSocket_handleOpensslInit(int bool_value)
void Log(enum LOG_LEVELS log_level, int msgno, const char *format,...)
const unsigned char * protos
ListElement * ListAppend(List *aList, void *content, size_t size)
int SSLSocket_getPendingRead(void)
void SSLSocket_terminate(void)
int SSLSocket_putdatas(SSL *ssl, int socket, char *buf0, size_t buf0len, PacketBuffers bufs)
#define SOCKETBUFFER_INTERRUPTED
int SocketBuffer_getQueuedChar(int socket, char *c)
int SSLSocket_close(networkHandles *net)
detail::named_arg< Char, T > arg(const Char *name, const T &arg)
int SSLSocket_initialize(void)
basic_userdata< reference > userdata
char * SocketBuffer_complete(int socket)
int ListRemoveHead(List *aList)
size_t MQTTProtocol_addressPort(const char *uri, int *port, const char **topic, int default_port)
#define TCPSOCKET_COMPLETE
ListElement * ListFindItem(List *aList, void *content, int(*callback)(void *, void *))
const char * privateKeyPassword
int intcompare(void *a, void *b)
int SocketBuffer_pendingWrite(int socket, int count, iobuf *iovecs, int *frees, size_t total, size_t bytes)
int(* ssl_error_cb)(const char *str, size_t len, void *u)
#define TCPSOCKET_INTERRUPTED
int SSLSocket_continueWrite(pending_writes *pw)
char * SSLSocket_getdata(SSL *ssl, int socket, size_t bytes, size_t *actual_len, int *rc)