Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef RTC_BASE_OPENSSL_UTILITY_H_ |
| 12 | #define RTC_BASE_OPENSSL_UTILITY_H_ |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 13 | |
| 14 | #include <openssl/ossl_typ.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 15 | |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 16 | #include <string> |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 17 | |
| 18 | namespace rtc { |
| 19 | // The openssl namespace holds static helper methods. All methods related |
| 20 | // to OpenSSL that are commonly used and don't require global state should be |
| 21 | // placed here. |
| 22 | namespace openssl { |
| 23 | // Verifies that the hostname provided matches that in the peer certificate |
| 24 | // attached to this SSL state. |
| 25 | bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host); |
| 26 | |
| 27 | // Logs all the errors in the OpenSSL errror queue from the current thread. A |
| 28 | // prefix can be provided for context. |
| 29 | void LogSSLErrors(const std::string& prefix); |
| 30 | |
Mirko Bonadei | b889a20 | 2018-08-15 11:41:27 +0200 | [diff] [blame] | 31 | #ifndef WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 32 | // Attempt to add the certificates from the loader into the SSL_CTX. False is |
| 33 | // returned only if there are no certificates returned from the loader or none |
| 34 | // of them can be added to the TrustStore for the provided context. |
| 35 | bool LoadBuiltinSSLRootCertificates(SSL_CTX* ssl_ctx); |
Mirko Bonadei | b889a20 | 2018-08-15 11:41:27 +0200 | [diff] [blame] | 36 | #endif // WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS |
Benjamin Wright | d6f86e8 | 2018-05-08 13:12:25 -0700 | [diff] [blame] | 37 | |
| 38 | } // namespace openssl |
| 39 | } // namespace rtc |
| 40 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 41 | #endif // RTC_BASE_OPENSSL_UTILITY_H_ |