SSLSocket.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*******************************************************************************
  2. * Copyright (c) 2009, 2018 IBM Corp.
  3. *
  4. * All rights reserved. This program and the accompanying materials
  5. * are made available under the terms of the Eclipse Public License v1.0
  6. * and Eclipse Distribution License v1.0 which accompany this distribution.
  7. *
  8. * The Eclipse Public License is available at
  9. * http://www.eclipse.org/legal/epl-v10.html
  10. * and the Eclipse Distribution License is available at
  11. * http://www.eclipse.org/org/documents/edl-v10.php.
  12. *
  13. * Contributors:
  14. * Ian Craggs, Allan Stockdill-Mander - initial implementation
  15. * Ian Craggs - SNI support
  16. * Ian Craggs - post connect checks and CApath
  17. *******************************************************************************/
  18. #if !defined(SSLSOCKET_H)
  19. #define SSLSOCKET_H
  20. #if defined(WIN32) || defined(WIN64)
  21. #define ssl_mutex_type HANDLE
  22. #else
  23. #include <pthread.h>
  24. #include <semaphore.h>
  25. #define ssl_mutex_type pthread_mutex_t
  26. #endif
  27. #include <openssl/ssl.h>
  28. #include "SocketBuffer.h"
  29. #include "Clients.h"
  30. #define URI_SSL "ssl://"
  31. /** if we should handle openssl initialization (bool_value == 1) or depend on it to be initalized externally (bool_value == 0) */
  32. void SSLSocket_handleOpensslInit(int bool_value);
  33. int SSLSocket_initialize(void);
  34. void SSLSocket_terminate(void);
  35. int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts, const char* hostname, size_t hostname_len);
  36. int SSLSocket_getch(SSL* ssl, int socket, char* c);
  37. char *SSLSocket_getdata(SSL* ssl, int socket, size_t bytes, size_t* actual_len);
  38. int SSLSocket_close(networkHandles* net);
  39. int SSLSocket_putdatas(SSL* ssl, int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees);
  40. int SSLSocket_connect(SSL* ssl, int sock, const char* hostname, int verify, int (*cb)(const char *str, size_t len, void *u), void* u);
  41. int SSLSocket_getPendingRead(void);
  42. int SSLSocket_continueWrite(pending_writes* pw);
  43. #endif