got FTP connection working
This commit is contained in:
parent
f15183d1f5
commit
6fec9c1ca9
7
launcher/Cargo.toml
Normal file
7
launcher/Cargo.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[package]
|
||||
name = "launcher"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
suppaftp = { version = "6.0.1", features = ["native-tls"] }
|
24
launcher/res/vsftpd.crt
Normal file
24
launcher/res/vsftpd.crt
Normal file
@ -0,0 +1,24 @@
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIID8TCCAtmgAwIBAgIUeFYZmMrAiIFZ9/QFwUS636XZrJMwDQYJKoZIhvcNAQEL
|
||||
BQAwgYcxCzAJBgNVBAYTAlVTMRAwDgYDVQQIDAdXeW9taW5nMREwDwYDVQQHDAhD
|
||||
aGV5ZW5uZTERMA8GA1UECgwIUGVyc29uYWwxGzAZBgNVBAMMEmdpdGVhLnBpd2Fs
|
||||
a2VyLm5ldDEjMCEGCSqGSIb3DQEJARYUc3dhbGtlckBwaXdhbGtlci5uZXQwHhcN
|
||||
MjQwNjIyMDAzNzEwWhcNMjUwNjIyMDAzNzEwWjCBhzELMAkGA1UEBhMCVVMxEDAO
|
||||
BgNVBAgMB1d5b21pbmcxETAPBgNVBAcMCENoZXllbm5lMREwDwYDVQQKDAhQZXJz
|
||||
b25hbDEbMBkGA1UEAwwSZ2l0ZWEucGl3YWxrZXIubmV0MSMwIQYJKoZIhvcNAQkB
|
||||
FhRzd2Fsa2VyQHBpd2Fsa2VyLm5ldDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
|
||||
AQoCggEBANOo7BOAUKhbBWodZqY8U34sQhK5Zj6WkVPQrFG1MWXX3KarDtBSuZ99
|
||||
PjbIoDR+Xm5MuNcJMnbeG4+EH6SrNsogHoyn7m8XJAQ/1N6kHEii4qeDzMIbcNu6
|
||||
7L54ZbONBw1Sygilnavp1iPY/2GzWH5ynaT4w4hQQrmDm8GlDNjxWGnw1CpOExAs
|
||||
LdUP3sF6RNtN6dX1vgYMo9ziNtRazRmDANXykgrfBrPCyjUGDsI9wnqm21qoaQ/s
|
||||
w506XovYI1Q6zWVu6cWUYyCFy4mABQxOOf7doJi4h6Wbxfp4WbNdcoBDHDN4nHzo
|
||||
pdrMzJ8GlZD0aCmmU+8ERvIk+IXY6+kCAwEAAaNTMFEwHQYDVR0OBBYEFJ/4/N4x
|
||||
fO/5nu/snApQO7Cw6CyCMB8GA1UdIwQYMBaAFJ/4/N4xfO/5nu/snApQO7Cw6CyC
|
||||
MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAMFwno+imd5ApXP4
|
||||
NsuX6db5GLiT6SHV65iactFUbnvqvK35KQMKVW03hOb2FPwAzEPARcPtFlENAWBl
|
||||
mHphDwAmfLbHXHdiTAKJNFO7D/AOB4TG6geBFlhYvwHCVS17nzFRJvF/0APlgbO8
|
||||
8f3XkmPBPudaGiuKHWdppdHCisk6CfYvNNnjguxihyUL/mDkwiKYQPcHsMYwdYM0
|
||||
QWCcTNyCjnFK/pbo6dLyPAFpXE9becSEhbxvFziNelADRflLkOUSd+sfxmoLMMsA
|
||||
EJajfocYQkAOiuh8uVzol9xsnKcZiujRoTSnndZsRVqfiNZaJbpvZoD/kY0aBXHo
|
||||
SIh5Ff4=
|
||||
-----END CERTIFICATE-----
|
15
launcher/src/main.rs
Normal file
15
launcher/src/main.rs
Normal file
@ -0,0 +1,15 @@
|
||||
use suppaftp::{NativeTlsFtpStream, NativeTlsConnector};
|
||||
use suppaftp::native_tls::{Certificate, TlsConnector, TlsStream};
|
||||
|
||||
fn main() {
|
||||
let ftp_stream = NativeTlsFtpStream::connect("gitea.piwalker.net:21").unwrap_or_else(|err|
|
||||
panic!("{}", err)
|
||||
);
|
||||
let cert = include_bytes!("../res/vsftpd.crt");
|
||||
let cert = Certificate::from_pem(cert).unwrap();
|
||||
let mut ftp_stream = ftp_stream.into_secure(NativeTlsConnector::from(TlsConnector::builder().add_root_certificate(cert).build().unwrap()), "gitea.piwalker.net").unwrap();
|
||||
assert!(ftp_stream.login("anonymous", "anonymous@").is_ok());
|
||||
|
||||
assert!(ftp_stream.quit().is_ok());
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user