| 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 |
| 11 | #ifndef RTC_BASE_OPENSSL_UTILITY_H_ |
| 12 | #define RTC_BASE_OPENSSL_UTILITY_H_ |
| 13 |
| 14 | #include <openssl/ossl_typ.h> |
| 15 |
| 16 | #include <string> |
| 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 |
| 24 | #ifdef OPENSSL_IS_BORINGSSL |
| 25 | // Does minimal parsing of a certificate (only verifying the presence of major |
| 26 | // fields), primarily for the purpose of extracting the relevant out |
| 27 | // parameters. Any that the caller is uninterested in can be null. |
| 28 | bool ParseCertificate(CRYPTO_BUFFER* cert_buffer, |
| 29 | CBS* signature_algorithm_oid, |
| 30 | int64_t* expiration_time); |
| 31 | #endif |
| 32 |
| 33 | // Verifies that the hostname provided matches that in the peer certificate |
| 34 | // attached to this SSL state. |
| 35 | // TODO(crbug.com/webrtc/11710): When OS certificate verification is available, |
| 36 | // skip compiling this as it adds a dependency on OpenSSL X509 objects, which we |
| 37 | // are trying to avoid in favor of CRYPTO_BUFFERs (see crbug.com/webrtc/11410). |
| 38 | bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host); |
| 39 |
| 40 | // Logs all the errors in the OpenSSL errror queue from the current thread. A |
| 41 | // prefix can be provided for context. |
| 42 | void LogSSLErrors(const std::string& prefix); |
| 43 |
| 44 | #ifndef WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS |
| 45 | // Attempt to add the certificates from the loader into the SSL_CTX. False is |
| 46 | // returned only if there are no certificates returned from the loader or none |
| 47 | // of them can be added to the TrustStore for the provided context. |
| 48 | bool LoadBuiltinSSLRootCertificates(SSL_CTX* ssl_ctx); |
| 49 | #endif // WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS |
| 50 |
| 51 | #ifdef OPENSSL_IS_BORINGSSL |
| 52 | CRYPTO_BUFFER_POOL* GetBufferPool(); |
| 53 | #endif |
| 54 |
| 55 | } // namespace openssl |
| 56 | } // namespace rtc |
| 57 |
| 58 | #endif // RTC_BASE_OPENSSL_UTILITY_H_ |
| 59 |