You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 line
598 B

  1. #include "ssl_process.h"
  2. SSLProcess::SSLProcess(bool isServer)
  3. : _ctx(0)
  4. , _isServer(isServer)
  5. {
  6. }
  7. SSLProcess::~SSLProcess()
  8. {
  9. if(!_ctx)
  10. SSL_CTX_free(_ctx);
  11. }
  12. void SSLProcess::sslInit()
  13. {
  14. // Load algorithms and error strings.
  15. ERR_load_crypto_strings();
  16. OpenSSL_add_all_algorithms();
  17. SSL_load_error_strings();
  18. SSL_library_init();
  19. // Create new context for server method.
  20. _ctx = SSL_CTX_new(
  21. _isServer ? SSLv23_server_method() : SSLv23_client_method());
  22. if(_ctx == 0)
  23. {
  24. ERR_print_errors_fp(stderr);
  25. exit(1);
  26. }
  27. }