forked from cadey/maj
unsafely disable TLS cert validation for now
This commit is contained in:
parent
d96a7a85bf
commit
02558b4dff
|
@ -10,7 +10,7 @@ edition = "2018"
|
||||||
num = "0.2"
|
num = "0.2"
|
||||||
num-derive = "0.3"
|
num-derive = "0.3"
|
||||||
num-traits = "0.2"
|
num-traits = "0.2"
|
||||||
rustls = { version = "0.18", optional = true }
|
rustls = { version = "0.18", optional = true, features = ["dangerous_configuration"] }
|
||||||
webpki = { version = "0.21.0", optional = true }
|
webpki = { version = "0.21.0", optional = true }
|
||||||
webpki-roots = { version = "0.20", optional = true }
|
webpki-roots = { version = "0.20", optional = true }
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use cursive::{
|
use cursive::{
|
||||||
event::Key,
|
event::Key,
|
||||||
menu::MenuTree,
|
menu::MenuTree,
|
||||||
theme::{BaseColor, Color, Effect, Style},
|
theme::{Effect, Style},
|
||||||
traits::*,
|
traits::*,
|
||||||
utils::markup::StyledString,
|
utils::markup::StyledString,
|
||||||
views::{Dialog, EditView, Panel, ResizedView, TextView},
|
views::{Dialog, EditView, Panel, ResizedView, TextView},
|
||||||
|
@ -53,7 +53,9 @@ fn help(siv: &mut Cursive) {
|
||||||
let content = include_str!("./help.gmi");
|
let content = include_str!("./help.gmi");
|
||||||
|
|
||||||
siv.add_layer(
|
siv.add_layer(
|
||||||
Dialog::around(Panel::new(TextView::new(render_gemini(content)).scrollable()))
|
Dialog::around(Panel::new(
|
||||||
|
TextView::new(render_gemini(content)).scrollable(),
|
||||||
|
))
|
||||||
.title("Help")
|
.title("Help")
|
||||||
.dismiss_button("Ok"),
|
.dismiss_button("Ok"),
|
||||||
);
|
);
|
||||||
|
@ -99,11 +101,15 @@ fn show(siv: &mut Cursive, url: &str, resp: Response) {
|
||||||
use StatusCode::*;
|
use StatusCode::*;
|
||||||
|
|
||||||
match resp.status {
|
match resp.status {
|
||||||
Success => {
|
Success => match str::from_utf8(&resp.body) {
|
||||||
match str::from_utf8(&resp.body) {
|
|
||||||
Ok(content) => {
|
Ok(content) => {
|
||||||
|
let content: StyledString = if resp.meta.starts_with("text/gemini") {
|
||||||
|
render_gemini(content)
|
||||||
|
} else {
|
||||||
|
StyledString::plain(content)
|
||||||
|
};
|
||||||
siv.add_fullscreen_layer(ResizedView::with_full_screen(
|
siv.add_fullscreen_layer(ResizedView::with_full_screen(
|
||||||
Dialog::around(TextView::new(render_gemini(content)).scrollable())
|
Dialog::around(TextView::new(content).scrollable())
|
||||||
.title(format!("{}: {}", url, resp.meta)),
|
.title(format!("{}: {}", url, resp.meta)),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -113,8 +119,7 @@ fn show(siv: &mut Cursive, url: &str, resp: Response) {
|
||||||
url, why
|
url, why
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
|
||||||
|
|
||||||
TemporaryRedirect => {
|
TemporaryRedirect => {
|
||||||
open(siv, resp.meta.as_str());
|
open(siv, resp.meta.as_str());
|
||||||
|
@ -141,10 +146,7 @@ fn render_gemini(body: &str) -> StyledString {
|
||||||
match node {
|
match node {
|
||||||
Text(line) => styled.append(StyledString::plain(line)),
|
Text(line) => styled.append(StyledString::plain(line)),
|
||||||
Link { to, name } => match name {
|
Link { to, name } => match name {
|
||||||
None => styled.append(StyledString::styled(
|
None => styled.append(StyledString::styled(to, Style::from(Effect::Underline))),
|
||||||
to,
|
|
||||||
Style::from(Effect::Underline),
|
|
||||||
)),
|
|
||||||
Some(name) => styled.append(StyledString::styled(
|
Some(name) => styled.append(StyledString::styled(
|
||||||
format!("{}: {}", to, name),
|
format!("{}: {}", to, name),
|
||||||
Style::from(Effect::Underline),
|
Style::from(Effect::Underline),
|
||||||
|
|
|
@ -5,10 +5,21 @@ use url::Url;
|
||||||
|
|
||||||
fn config() -> ClientConfig {
|
fn config() -> ClientConfig {
|
||||||
let mut config = ClientConfig::new();
|
let mut config = ClientConfig::new();
|
||||||
|
config.dangerous().set_certificate_verifier(Arc::new(NoCertificateVerification{}));
|
||||||
|
|
||||||
config
|
config
|
||||||
.root_store
|
}
|
||||||
.add_server_trust_anchors(&webpki_roots::TLS_SERVER_ROOTS);
|
|
||||||
config
|
struct NoCertificateVerification {}
|
||||||
|
|
||||||
|
impl rustls::ServerCertVerifier for NoCertificateVerification {
|
||||||
|
fn verify_server_cert(&self,
|
||||||
|
_roots: &rustls::RootCertStore,
|
||||||
|
_presented_certs: &[rustls::Certificate],
|
||||||
|
_dns_name: webpki::DNSNameRef<'_>,
|
||||||
|
_ocsp: &[u8]) -> Result<rustls::ServerCertVerified, rustls::TLSError> {
|
||||||
|
Ok(rustls::ServerCertVerified::assertion())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
|
|
Loading…
Reference in New Issue