blob: a2e49dfdbd5aea50b2d296d76167319bf83feb17 [file] [log] [blame]
Benjamin Wrightd6f86e82018-05-08 13:12:25 -07001/*
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 Anton10542f22019-01-11 09:11:00 -080011#ifndef RTC_BASE_OPENSSL_UTILITY_H_
12#define RTC_BASE_OPENSSL_UTILITY_H_
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070013
14#include <openssl/ossl_typ.h>
15#include <string>
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070016
17namespace rtc {
18// The openssl namespace holds static helper methods. All methods related
19// to OpenSSL that are commonly used and don't require global state should be
20// placed here.
21namespace openssl {
22// Verifies that the hostname provided matches that in the peer certificate
23// attached to this SSL state.
24bool VerifyPeerCertMatchesHost(SSL* ssl, const std::string& host);
25
26// Logs all the errors in the OpenSSL errror queue from the current thread. A
27// prefix can be provided for context.
28void LogSSLErrors(const std::string& prefix);
29
Mirko Bonadeib889a202018-08-15 11:41:27 +020030#ifndef WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070031// Attempt to add the certificates from the loader into the SSL_CTX. False is
32// returned only if there are no certificates returned from the loader or none
33// of them can be added to the TrustStore for the provided context.
34bool LoadBuiltinSSLRootCertificates(SSL_CTX* ssl_ctx);
Mirko Bonadeib889a202018-08-15 11:41:27 +020035#endif // WEBRTC_EXCLUDE_BUILT_IN_SSL_ROOT_CERTS
Benjamin Wrightd6f86e82018-05-08 13:12:25 -070036
37} // namespace openssl
38} // namespace rtc
39
Steve Anton10542f22019-01-11 09:11:00 -080040#endif // RTC_BASE_OPENSSL_UTILITY_H_