Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ftps_manual to ServerBuilder #522

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/server/ftpserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod listen;
mod listen_proxied;
pub mod options;

use rustls::ServerConfig;
use super::{
controlchan,
failed_logins::FailedLoginsCache,
Expand Down Expand Up @@ -259,6 +260,22 @@ where
self
}

/// Enables FTPS by configuring the raw FtpsConfig.
///
/// # Example
///
/// ```rust
/// use libunftp::Server;
/// use unftp_sbe_fs::ServerExt;
///
/// let server = Server::with_fs("/tmp")
/// .ftps_manual(config);
/// ```
pub fn ftps_manual<P: Into<PathBuf>>(mut self, config: Arc<ServerConfig>) -> Self {
self.ftps_mode = FtpsConfig::On { tls_config: config };
self
}

/// Allows switching on Mutual TLS. For this to work the trust anchors also needs to be set using
/// the [ftps_trust_store](crate::ServerBuilder::ftps_trust_store) method.
///
Expand Down
1 change: 1 addition & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ pub(crate) use controlchan::reply::{Reply, ReplyCode};
pub(crate) use controlchan::ControlChanMiddleware;
pub(crate) use controlchan::Event;
pub(crate) use controlchan::{ControlChanError, ControlChanErrorKind};

use session::{Session, SessionState};
1 change: 0 additions & 1 deletion src/server/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ fn load_certs<P: AsRef<Path>>(filename: P) -> Result<Vec<CertificateDer<'static>
}

fn load_private_key<P: AsRef<Path>>(filename: P) -> Result<PrivateKeyDer<'static>, ConfigError> {
use rustls::pki_types::PrivateKeyDer;
use rustls_pemfile::{read_one, Item};
use std::iter;

Expand Down