SSLSocket.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*******************************************************************************
  2. * Copyright (c) 2009, 2017 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. *******************************************************************************/
  17. #if !defined(SSLSOCKET_H)
  18. #define SSLSOCKET_H
  19. #if defined(WIN32) || defined(WIN64)
  20. #define ssl_mutex_type HANDLE
  21. #else
  22. #include <pthread.h>
  23. #include <semaphore.h>
  24. #define ssl_mutex_type pthread_mutex_t
  25. #endif
  26. #include <openssl/ssl.h>
  27. #include "SocketBuffer.h"
  28. #include "Clients.h"
  29. #define URI_SSL "ssl://"
  30. /** if we should handle openssl initialization (bool_value == 1) or depend on it to be initalized externally (bool_value == 0) */
  31. void SSLSocket_handleOpensslInit(int bool_value);
  32. int SSLSocket_initialize(void);
  33. void SSLSocket_terminate(void);
  34. int SSLSocket_setSocketForSSL(networkHandles* net, MQTTClient_SSLOptions* opts, char* hostname);
  35. int SSLSocket_getch(SSL* ssl, int socket, char* c);
  36. char *SSLSocket_getdata(SSL* ssl, int socket, size_t bytes, size_t* actual_len);
  37. int SSLSocket_close(networkHandles* net);
  38. int SSLSocket_putdatas(SSL* ssl, int socket, char* buf0, size_t buf0len, int count, char** buffers, size_t* buflens, int* frees);
  39. int SSLSocket_connect(SSL* ssl, int socket);
  40. int SSLSocket_getPendingRead(void);
  41. int SSLSocket_continueWrite(pending_writes* pw);
  42. #endif