verifiedtlstransport.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /**
  2. * Copyright (c) 2020 Paul-Louis Ageneau
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with this library; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #include "verifiedtlstransport.hpp"
  19. #include "common.hpp"
  20. #if RTC_ENABLE_WEBSOCKET
  21. namespace rtc::impl {
  22. VerifiedTlsTransport::VerifiedTlsTransport(shared_ptr<TcpTransport> lower, string host,
  23. state_callback callback)
  24. : TlsTransport(std::move(lower), std::move(host), std::move(callback)) {
  25. #if USE_GNUTLS
  26. PLOG_DEBUG << "Setting up TLS certificate verification";
  27. gnutls_session_set_verify_cert(mSession, mHost.c_str(), 0);
  28. #else
  29. PLOG_DEBUG << "Setting up TLS certificate verification";
  30. SSL_set_verify(mSsl, SSL_VERIFY_PEER, NULL);
  31. SSL_set_verify_depth(mSsl, 4);
  32. #endif
  33. }
  34. VerifiedTlsTransport::~VerifiedTlsTransport() {}
  35. } // namespace rtc::impl
  36. #endif