GithubHelp home page GithubHelp logo

Implicit SSL example about suppaftp HOT 10 CLOSED

veeso avatar veeso commented on May 25, 2024
Implicit SSL example

from suppaftp.

Comments (10)

veeso avatar veeso commented on May 25, 2024

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

from suppaftp.

IsaacJReay avatar IsaacJReay commented on May 25, 2024

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

from suppaftp.

veeso avatar veeso commented on May 25, 2024

I can try to release it in two days

from suppaftp.

veeso avatar veeso commented on May 25, 2024

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.

from suppaftp.

yyyymux avatar yyyymux commented on May 25, 2024

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!

from suppaftp.

veeso avatar veeso commented on May 25, 2024

You should try some options of the tls builder:

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

from suppaftp.

yyyymux avatar yyyymux commented on May 25, 2024

thanks!

from suppaftp.

svet-b avatar svet-b commented on May 25, 2024

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?

from suppaftp.

veeso avatar veeso commented on May 25, 2024

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

from suppaftp.

svet-b avatar svet-b commented on May 25, 2024

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();

from suppaftp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.