feat: add oid const
This commit is contained in:
11
src/x509.rs
11
src/x509.rs
@@ -2,6 +2,12 @@ use x509_parser::parse_x509_certificate;
|
||||
use x509_parser::pem::parse_x509_pem;
|
||||
use x509_parser::extensions::ParsedExtension;
|
||||
use x509_parser::der_parser::oid::Oid;
|
||||
use std::str::FromStr;
|
||||
|
||||
lazy_static! {
|
||||
static ref OID_COMMON_NAME: Oid<'static> = Oid::from_str("2.5.4.3").unwrap();
|
||||
static ref OID_RSA_WITH_SHA256: Oid<'static> = Oid::from_str("1.2.840.113549.1.1.11").unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_x509() {
|
||||
@@ -11,8 +17,7 @@ fn test_x509() {
|
||||
// println!("{:?}", cert);
|
||||
// println!("{:#?}", cert.subject().iter_common_name());
|
||||
cert.subject().iter_common_name().for_each(|c| {
|
||||
use std::str::FromStr;
|
||||
if c.attr_type == Oid::from_str("2.5.4.3").unwrap() {
|
||||
if c.attr_type == *OID_COMMON_NAME {
|
||||
println!("{:?}", c.attr_value.content.as_str().unwrap());
|
||||
}
|
||||
});
|
||||
@@ -25,4 +30,6 @@ fn test_x509() {
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
println!("{:?}", cert.signature_algorithm.algorithm);
|
||||
println!("{:?}", cert.signature_algorithm.algorithm.bytes());
|
||||
}
|
||||
Reference in New Issue
Block a user