BBS2chProxySecureSocket.h 813 B

1234567891011121314151617181920212223242526272829303132
  1. #pragma once
  2. #ifdef USE_MITM
  3. #include "IBBS2chProxySocket.h"
  4. #ifdef USE_GNUTLS
  5. #include <gnutls/gnutls.h>
  6. #else
  7. #include <openssl/ssl.h>
  8. #endif
  9. class BBS2chProxySecureSocket : public IBBS2chProxySocket {
  10. public:
  11. BBS2chProxySecureSocket(int sock, const char *host);
  12. ~BBS2chProxySecureSocket();
  13. static int initializeCerts(const char *certPath, const char *keyPath);
  14. static void generateAndPrintSelfSignedCertificate(void);
  15. virtual int read(char *buffer, int length);
  16. virtual int readLine(char *buffer, int maxLength);
  17. virtual int write(const char *buffer, int length);
  18. virtual int writeString(const std::string &str);
  19. virtual void close(void);
  20. private:
  21. int socket;
  22. #ifdef USE_GNUTLS
  23. gnutls_session_t session;
  24. gnutls_certificate_credentials_t x509_cred;
  25. #else
  26. SSL_CTX *ctx;
  27. SSL *ssl;
  28. #endif
  29. };
  30. #endif