ASN.1 decode
This commit is contained in:
parent
b19bc06a34
commit
7ef50fd78e
7
Cargo.lock
generated
7
Cargo.lock
generated
@ -67,6 +67,12 @@ version = "1.0.97"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "base64"
|
||||||
|
version = "0.22.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.10.0"
|
version = "1.10.0"
|
||||||
@ -424,6 +430,7 @@ name = "scep_req_parser"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"base64",
|
||||||
"clap",
|
"clap",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"http",
|
"http",
|
||||||
|
@ -9,4 +9,5 @@ env_logger = "0.11.6"
|
|||||||
clap = { version = "4.5.31", features = ["derive", "env"] }
|
clap = { version = "4.5.31", features = ["derive", "env"] }
|
||||||
http = { version = "1.2.0" }
|
http = { version = "1.2.0" }
|
||||||
anyhow = "1.0.97"
|
anyhow = "1.0.97"
|
||||||
url = "2.5.4"
|
url = "2.5.4"
|
||||||
|
base64 = "0.22.1"
|
15
src/main.rs
15
src/main.rs
@ -2,7 +2,11 @@ use clap::Parser;
|
|||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
use base64::alphabet::STANDARD;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
use base64::prelude::*;
|
||||||
|
use base64::Engine as _;
|
||||||
|
use base64::engine::general_purpose::URL_SAFE as BASE64_URL_URL_SAFE;
|
||||||
|
|
||||||
/// Simple SCEP parser program
|
/// Simple SCEP parser program
|
||||||
#[derive(Parser, Debug)]
|
#[derive(Parser, Debug)]
|
||||||
@ -102,7 +106,7 @@ fn parse_response(req: &[u8]) -> anyhow::Result<http::Response<Vec<u8>>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone)]
|
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||||
enum Operation {
|
enum Operation {
|
||||||
GetCACaps,
|
GetCACaps,
|
||||||
GetCACert,
|
GetCACert,
|
||||||
@ -136,4 +140,13 @@ fn main() {
|
|||||||
|
|
||||||
|
|
||||||
println!("{} - {} - {op:?}", response.headers().get("Date").unwrap().to_str().unwrap(), response.status().as_u16());
|
println!("{} - {} - {op:?}", response.headers().get("Date").unwrap().to_str().unwrap(), response.status().as_u16());
|
||||||
|
|
||||||
|
// Parse details about PKIOperation request
|
||||||
|
// https://www.rfc-editor.org/rfc/rfc8894.html#section-4.3
|
||||||
|
if op == Operation::PKIOperation {
|
||||||
|
let req_b64 = BASE64_URL_URL_SAFE.encode(&request.body());
|
||||||
|
let res_b64 = BASE64_URL_URL_SAFE.encode(&response.body());
|
||||||
|
println!("https://lapo.it/asn1js/#{req_b64}");
|
||||||
|
println!("https://lapo.it/asn1js/#{res_b64}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user