ssl_session.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2018 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_TSI_SSL_SESSION_CACHE_SSL_SESSION_H
20 #define GRPC_CORE_TSI_SSL_SESSION_CACHE_SSL_SESSION_H
21 
23 
24 #include <memory>
25 
26 #include <openssl/ssl.h>
27 
28 #include <grpc/slice.h>
29 
31 
32 // The main purpose of code here is to provide means to cache SSL sessions
33 // in a way that they can be shared between connections.
34 //
35 // SSL_SESSION stands for single instance of session and is not generally safe
36 // to share between SSL contexts with different lifetimes. It happens because
37 // not all SSL implementations guarantee immutability of SSL_SESSION object.
38 // See SSL_SESSION documentation in BoringSSL and OpenSSL for more details.
39 
40 namespace tsi {
41 
43  void operator()(SSL_SESSION* session) { SSL_SESSION_free(session); }
44 };
45 
46 typedef std::unique_ptr<SSL_SESSION, SslSessionDeleter> SslSessionPtr;
47 
52  public:
53  // Not copyable nor movable.
54  SslCachedSession(const SslCachedSession&) = delete;
56 
58  static std::unique_ptr<SslCachedSession> Create(SslSessionPtr session);
59 
60  virtual ~SslCachedSession() = default;
61 
63  virtual SslSessionPtr CopySession() const = 0;
64 
65  protected:
66  SslCachedSession() = default;
67 };
68 
69 } // namespace tsi
70 
71 #endif /* GRPC_CORE_TSI_SSL_SESSION_CACHE_SSL_SESSION_H */
slice.h
tsi::SslCachedSession
Definition: ssl_session.h:51
tsi::SslCachedSession::SslCachedSession
SslCachedSession()=default
tsi::SslSessionPtr
std::unique_ptr< SSL_SESSION, SslSessionDeleter > SslSessionPtr
Definition: ssl_session.h:46
tsi::SslCachedSession::~SslCachedSession
virtual ~SslCachedSession()=default
tsi::SslCachedSession::CopySession
virtual SslSessionPtr CopySession() const =0
Returns a copy of previously cached session.
ssl.h
tsi::SslSessionDeleter
Definition: ssl_session.h:42
ssl_session_st
Definition: third_party/boringssl-with-bazel/src/ssl/internal.h:3787
ref_counted.h
tsi::SslCachedSession::operator=
SslCachedSession & operator=(const SslCachedSession &)=delete
tsi
Definition: ssl_key_logging.cc:29
SSL_SESSION_free
#define SSL_SESSION_free
Definition: boringssl_prefix_symbols.h:241
tsi::SslSessionDeleter::operator()
void operator()(SSL_SESSION *session)
Definition: ssl_session.h:43
tsi::SslCachedSession::Create
static std::unique_ptr< SslCachedSession > Create(SslSessionPtr session)
Create single cached instance of session.
Definition: ssl_session_openssl.cc:70
port_platform.h


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:01:21