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

Second example on the docs home page doesn't build #18

Open
sp1ff opened this issue Apr 12, 2023 · 0 comments
Open

Second example on the docs home page doesn't build #18

sp1ff opened this issue Apr 12, 2023 · 0 comments

Comments

@sp1ff
Copy link

sp1ff commented Apr 12, 2023

Example:

use async_ftp::FtpStream;
use std::convert::TryFrom;
use tokio_rustls::rustls::{ClientConfig, RootCertStore, ServerName};

#[tokio::main]
async fn main() {
    let ftp_stream = FtpStream::connect("lettir.orangewebsite.com:21")
        .await
        .unwrap();

    let mut root_store = RootCertStore::empty();
    // root_store.add_pem_file(...);
    let conf = ClientConfig::builder()
        .with_safe_defaults()
        .with_root_certificates(root_store)
        .with_no_client_auth();
    let domain = ServerName::try_from("lettir.orangewebsite.com").expect("invalid DNS name");

    // Switch to the secure mode
    let mut ftp_stream = ftp_stream.into_secure(conf, domain).await.unwrap();
    ftp_stream.login("anonymous", "anonymous").await.unwrap();
    // Do other secret stuff
    // Switch back to the insecure mode (if required)
    let mut ftp_stream = ftp_stream.into_insecure().await.unwrap();
    // Do all public stuff
    let _ = ftp_stream.quit().await;
}

gives:

error[E0308]: arguments to this function are incorrect
  --> src/main.rs:20:37
   |
20 |     let mut ftp_stream = ftp_stream.into_secure(conf, domain).await.unwrap();
   |                                     ^^^^^^^^^^^ ----  ------ expected enum `rustls::client::client_conn::ServerName`, found enum `tokio_rustls::rustls::ServerName`
   |                                                 |
   |                                                 expected struct `rustls::client::client_conn::ClientConfig`, found struct `ClientConfig`
   |
   = note: perhaps two different versions of crate `rustls` are being used?
   = note: perhaps two different versions of crate `rustls` are being used?
note: associated function defined here
  --> /home/mgh/.cargo/registry/src/github.com-1ecc6299db9ec823/async_ftp-6.0.0/src/ftp.rs:87:18
   |
87 |     pub async fn into_secure(mut self, config: ClientConfig, domain: ServerName) -> Result<FtpStream> {
   |                  ^^^^^^^^^^^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant