Skip to content

Commit ddc94a9

Browse files
authored
Merge pull request #11 from jacob-pro/main
Allow changing certificate at runtime
2 parents 59b4b19 + 7e3c46a commit ddc94a9

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.4.2 - 2022-04-09
4+
5+
### Added
6+
7+
- Added [TlsListener::replace_acceptor()] function to allow replacing the listener certificate at runtime.
8+
39
## 0.4.1 - 2022-04-09
410

511
### Changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "tls-listener"
33
description = "wrap incoming Stream of connections in TLS"
4-
version = "0.4.1"
4+
version = "0.4.2"
55
authors = ["Thayne McCombs <[email protected]>"]
66
repository = "https://github.com/tmccombs/tls-listener"
77
edition = "2018"

src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
use futures_util::stream::{FuturesUnordered, Stream, StreamExt};
1818
use pin_project_lite::pin_project;
1919
use std::future::Future;
20-
use std::io;
2120
use std::marker::Unpin;
2221
use std::pin::Pin;
2322
use std::task::{Context, Poll};
2423
use std::time::Duration;
24+
use std::{io, mem};
2525
use thiserror::Error;
2626
use tokio::io::{AsyncRead, AsyncWrite};
2727
use tokio::time::{timeout, Timeout};
@@ -136,6 +136,13 @@ where
136136
pub fn accept(&mut self) -> impl Future<Output = Option<<Self as Stream>::Item>> + '_ {
137137
self.next()
138138
}
139+
140+
/// Replaces the Tls Acceptor configuration, which will be used for new connections.
141+
///
142+
/// This can be used to change the certificate used at runtime.
143+
pub fn replace_acceptor(&mut self, acceptor: T) {
144+
self.tls = acceptor;
145+
}
139146
}
140147

141148
impl<A, T> Stream for TlsListener<A, T>

0 commit comments

Comments
 (0)