forked from cadey/maj
cert info
This commit is contained in:
parent
04a0c8e988
commit
cd6ef8a516
|
@ -19,7 +19,7 @@ tokio-rustls = { version = "0.14", features = ["dangerous_configuration"], optio
|
|||
webpki = { version = "0.21.0", optional = true }
|
||||
webpki-roots = { version = "0.20", optional = true }
|
||||
tokio = { version = "0.2", features = ["full"], optional = true }
|
||||
async-tls = { version = "0.9.0", default-features = false, optional = true }
|
||||
async-tls = { default-features = false, optional = true, git = "https://github.com/Xe/async-tls" }
|
||||
async-std = { version = "1.6", optional = true }
|
||||
log = "0.4"
|
||||
url = "2"
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use async_std::task;
|
||||
use maj::{
|
||||
gemini::Builder,
|
||||
route, seg,
|
||||
server::{Error, Handler as MajHandler, Request},
|
||||
split, Response,
|
||||
|
@ -97,8 +98,16 @@ async fn majc() -> Result<maj::Response, maj::server::Error> {
|
|||
Ok(Response::gemini(msg.to_vec()))
|
||||
}
|
||||
|
||||
async fn need_cert() -> Result<Response, Error> {
|
||||
Ok(Response::need_cert("test"))
|
||||
async fn need_cert(req: Request) -> Result<Response, Error> {
|
||||
match req.certs {
|
||||
None => Ok(Response::need_cert("test")),
|
||||
Some(certs) => Ok(Response::render(
|
||||
Builder::new()
|
||||
.heading(1, "Cert test")
|
||||
.text(format!("{:?}", certs))
|
||||
.build(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
@ -117,7 +126,7 @@ impl MajHandler for Handler {
|
|||
|
||||
route!(req.url.path(), {
|
||||
(/) => index().await;
|
||||
(/"cert") => need_cert().await;
|
||||
(/"cert") => need_cert(req).await;
|
||||
(/"majc") => majc().await;
|
||||
});
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ async fn handle_request(
|
|||
|
||||
let req = Request {
|
||||
url: url,
|
||||
certs: None,
|
||||
certs: stream.peer_certificates(),
|
||||
};
|
||||
handle(h, req, &mut stream, addr).await;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue