Fix some gratuitous compile failures under OpenSSL

To test:
- ensure openssl files live in /usr/include/openssl
- make a config with the following values:
```
   rtc_build_ssl = false
   rtc_ssl_root = "/usr/include/openssl
```
- compile rtc_unittests

There will be link errors, but no compile errors.

Bug: None
Change-Id: I3d28b1613e11a716b11c7def808100ef58ab75f5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/358300
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42714}
This commit is contained in:
Harald Alvestrand 2024-08-01 13:20:06 +00:00 committed by WebRTC LUCI CQ
parent 5d6fa7d2fc
commit 7079843bc8

View File

@ -35,6 +35,15 @@ SSL_CTX* NewTlsContext() {
return SSL_CTX_new(TLS_method());
#endif
}
SSL_SESSION* NewSslSession(SSL_CTX* ssl_ctx) {
#ifdef OPENSSL_IS_BORINGSSL
return SSL_SESSION_new(ssl_ctx);
#else
return SSL_SESSION_new();
#endif
}
} // namespace
namespace rtc {
@ -79,7 +88,7 @@ TEST(OpenSSLSessionCache, InvalidLookupReturnsNullptr) {
TEST(OpenSSLSessionCache, SimpleValidSessionLookup) {
SSL_CTX* ssl_ctx = NewDtlsContext();
SSL_SESSION* ssl_session = SSL_SESSION_new(ssl_ctx);
SSL_SESSION* ssl_session = NewSslSession(ssl_ctx);
OpenSSLSessionCache session_cache(SSL_MODE_DTLS, ssl_ctx);
session_cache.AddSession("webrtc.org", ssl_session);
@ -90,8 +99,8 @@ TEST(OpenSSLSessionCache, SimpleValidSessionLookup) {
TEST(OpenSSLSessionCache, AddToExistingReplacesPrevious) {
SSL_CTX* ssl_ctx = NewDtlsContext();
SSL_SESSION* ssl_session_1 = SSL_SESSION_new(ssl_ctx);
SSL_SESSION* ssl_session_2 = SSL_SESSION_new(ssl_ctx);
SSL_SESSION* ssl_session_1 = NewSslSession(ssl_ctx);
SSL_SESSION* ssl_session_2 = NewSslSession(ssl_ctx);
OpenSSLSessionCache session_cache(SSL_MODE_DTLS, ssl_ctx);
session_cache.AddSession("webrtc.org", ssl_session_1);