File tree Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Expand file tree Collapse file tree 2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -234,3 +234,23 @@ void TcpServer::enableSSL(
234
234
.setValidate (caPath.empty () ? false : true );
235
235
sslContextPtr_ = newSSLContext (*policyPtr_, true );
236
236
}
237
+
238
+ void TcpServer::reloadSSL ()
239
+ {
240
+ if (loop_->isInLoopThread ())
241
+ {
242
+ if (policyPtr_)
243
+ {
244
+ sslContextPtr_ = newSSLContext (*policyPtr_, true );
245
+ }
246
+ }
247
+ else
248
+ {
249
+ loop_->queueInLoop ([this ]() {
250
+ if (policyPtr_)
251
+ {
252
+ sslContextPtr_ = newSSLContext (*policyPtr_, true );
253
+ }
254
+ });
255
+ }
256
+ }
Original file line number Diff line number Diff line change @@ -260,6 +260,14 @@ class TRANTOR_EXPORT TcpServer : NonCopyable
260
260
sslContextPtr_ = newSSLContext (*policyPtr_, true );
261
261
}
262
262
263
+ /* *
264
+ * @brief Reload the SSL context.
265
+ * @note Call this function when the certificate or private key is updated.
266
+ * The server will reload the SSL context and use the new certificate and
267
+ * private key. new connections will use the new SSL context.
268
+ */
269
+ void reloadSSL ();
270
+
263
271
private:
264
272
void handleCloseInLoop (const TcpConnectionPtr &connectionPtr);
265
273
void newConnection (int fd, const InetAddress &peer);
You can’t perform that action at this time.
0 commit comments