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

Implicit SSL example #14

Closed
IsaacJReay opened this issue Jun 23, 2022 · 10 comments · Fixed by #15
Closed

Implicit SSL example #14

IsaacJReay opened this issue Jun 23, 2022 · 10 comments · Fixed by #15
Assignees
Labels
good first issue Good for newcomers new feature A new feature request question Further information is requested

Comments

@IsaacJReay
Copy link

Hello developers, I recently used your crate and found it to be very interesting. Everything just works. However, I cannot seems to find way to connect when using implicit ssl settings. Filezilla seems to be working fine. Whenever I tried to connect it via the explicit method, it hanged at ftpstream::connect. Maybe this isn't the right way to connect. Could you show me how to do it? Thanks

@IsaacJReay IsaacJReay added the question Further information is requested label Jun 23, 2022
@veeso
Copy link
Owner

veeso commented Jun 24, 2022

I don't think it's supported at the moment, but I can work on it

@IsaacJReay
Copy link
Author

Really appreciate your efforts. Is asking for ETA ok? Thanks

@veeso veeso added the new feature A new feature request label Jun 27, 2022
@veeso
Copy link
Owner

veeso commented Jun 27, 2022

I can try to release it in two days

@veeso veeso mentioned this issue Jun 27, 2022
4 tasks
@veeso veeso linked a pull request Jun 27, 2022 that will close this issue
4 tasks
@veeso
Copy link
Owner

veeso commented Jun 27, 2022

The feature is now available in suppaftp 4.3.0, please see the example below:

use suppaftp::FtpStream;
use suppaftp::native_tls::{TlsConnector, TlsStream};
use std::path::Path;
// Create a TlsConnector
// NOTE: For custom options see <https://docs.rs/native-tls/0.2.6/native_tls/struct.TlsConnectorBuilder.html>
let mut ctx = TlsConnector::new().unwrap();
let mut ftp_stream = FtpStream::connect_secure_implicit("127.0.0.1:990", ctx, "localhost").unwrap();

In order to enable the connect_secure_implicit method, you have to compile suppaftp with the deprecated feature.

@veeso veeso closed this as completed Jun 27, 2022
@veeso veeso added the good first issue Good for newcomers label Jun 27, 2022
@veeso veeso pinned this issue Jun 27, 2022
@yyyymux
Copy link

yyyymux commented Aug 1, 2022

Hello, Developer and Landlord,when i called into_secure, it hanged at " SecureError("error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed: " , How to add certificates for clients? thank you!

@veeso
Copy link
Owner

veeso commented Aug 1, 2022

You should try some options of the tls builder:

let ctx = TlsConnector::builder()
                .danger_accept_invalid_certs(true)
                .danger_accept_invalid_hostnames(true)
                .build()

@yyyymux
Copy link

yyyymux commented Aug 2, 2022

thanks!

@svet-b
Copy link

svet-b commented Apr 13, 2023

Is this still supported in the latest version? With the "deprecated", "native-tls" features enabled, and the sample code

use suppaftp::FtpStream;
use suppaftp::native_tls::{TlsConnector, TlsStream};

let mut ctx = TlsConnector::new().unwrap();
let mut ftp_stream = FtpStream::connect_secure_implicit("127.0.0.1:990", ctx, "localhost").unwrap();

I get the error

error[E0277]: the trait bound `native_tls::TlsConnector: suppaftp::sync_ftp::tls::TlsConnector` is not satisfied
   --> src/interfaces/ftp.rs:63:82
    |
63  |         let mut ftp_stream = FtpStream::connect_secure_implicit("127.0.0.1:990", ctx, "localhost").unwrap();
    |                              ----------------------------------                  ^^^ the trait `suppaftp::sync_ftp::tls::TlsConnector` is not implemented for `native_tls::TlsConnector`
    |                              |
    |                              required by a bound introduced by this call
    |
    = help: the trait `suppaftp::sync_ftp::tls::TlsConnector` is implemented for `NativeTlsConnector`
note: required by a bound in `ImplFtpStream::<T>::connect_secure_implicit`
   --> /Users/svet/.cargo/registry/src/github.com-1ecc6299db9ec823/suppaftp-5.1.1/src/sync_ftp/mod.rs:184:29
    |
184 |         tls_connector: impl TlsConnector<Stream = T> + 'static,
    |                             ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ImplFtpStream::<T>::connect_secure_implicit`

If I follow the "help" hint and instead set ctx to

let mut ctx = NativeTlsConnector::from(TlsConnector::new().unwrap());

I get a type mismatch on it:

error[E0271]: type mismatch resolving `<NativeTlsConnector as suppaftp::sync_ftp::tls::TlsConnector>::Stream == suppaftp::sync_ftp::tls::NoTlsStream`
   --> src/interfaces/ftp.rs:64:82
    |
64  |         let mut ftp_stream = FtpStream::connect_secure_implicit("127.0.0.1:990", ctx, "localhost").unwrap();
    |                              ----------------------------------                  ^^^ expected struct `suppaftp::sync_ftp::tls::NoTlsStream`, found struct `suppaftp::sync_ftp::tls::native_tls::NativeTlsStream`
    |                              |
    |                              required by a bound introduced by this call

Any hints as to how to go about this?

@veeso
Copy link
Owner

veeso commented Apr 13, 2023

@svet-b you're using the wrong type. You need to use NativeTlsFtpStream and not FtpStream

@svet-b
Copy link

svet-b commented Apr 13, 2023

Thanks for the quick response @veeso - really appreciate your help here!

The following indeed seems to work 👍

use suppaftp::{NativeTlsConnector, NativeTlsFtpStream};
use suppaftp::native_tls::TlsConnector;

let mut ctx = NativeTlsConnector::from(TlsConnector::new().unwrap());
let mut ftp_stream = NativeTlsFtpStream::connect_secure_implicit("127.0.0.1:990", ctx, "localhost").unwrap();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers new feature A new feature request question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants