use tokio_gemini::{ certs::{ fingerprint::{self, CertFingerprint}, SelfsignedCertVerifier, }, Client, LibError, }; // Much simpler than examples/main.rs // Hardcoded URL, no cert check, always write to stdout // // cargo add tokio-gemini // cargo add tokio -F macros,rt-multi-thread // const URL: &str = "gemini://geminiprotocol.net/docs/protocol-specification.gmi"; #[tokio::main] async fn main() -> Result<(), LibError> { let client = Client::builder() .with_selfsigned_cert_verifier(CertVerifier) .build(); match client.request(URL).await?.ensure_ok() { Ok(mut resp) => { println!("{}", resp.text().await?); } Err(resp) => { println!("{} {}", resp.status().num(), resp.message()); } } Ok(()) } struct CertVerifier; impl SelfsignedCertVerifier for CertVerifier { fn verify( &self, cert: &tokio_gemini::certs::CertificateDer, host: &str, _now: tokio_gemini::certs::UnixTime, ) -> Result { // For real verification example with known_hosts file // see examples/main.rs eprintln!( "Host = {}\nFingerprint = {}", host, CertFingerprint::::new(cert).base64(), ); Ok(true) } }