openssl_utility.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright 2018 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #ifndef RTC_BASE_OPENSSL_UTILITY_H_
  11. #define RTC_BASE_OPENSSL_UTILITY_H_
  12. #include <openssl/ossl_typ.h>
  13. #include <string>
  14. namespace rtc {
  15. // The openssl namespace holds static helper methods. All methods related
  16. // to OpenSSL that are commonly used and don't require global state should be
  17. // placed here.
  18. namespace openssl {
  19. // Verifies that the hostname provided matches that in the peer certificate
  20. // attached to this SSL state.
  21. bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host);
  22. // Logs all the errors in the OpenSSL errror queue from the current thread. A
  23. // prefix can be provided for context.
  24. void LogSSLErrors(const std::string& prefix);
  25. #ifndef WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS
  26. // Attempt to add the certificates from the loader into the SSL_CTX. False is
  27. // returned only if there are no certificates returned from the loader or none
  28. // of them can be added to the TrustStore for the provided context.
  29. bool LoadBuiltinSSLRootCertificates(SSL_CTX* ssl_ctx);
  30. #endif // WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS
  31. } // namespace openssl
  32. } // namespace rtc
  33. #endif // RTC_BASE_OPENSSL_UTILITY_H_