diff --git a/src/lib.rs b/src/lib.rs
index 6bd6aeb..d74dd82 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -17,7 +17,6 @@
* along with this program. If not, see .
*/
-use console::style;
use openssl::asn1::Asn1Time;
use openssl::hash::MessageDigest;
use openssl::nid::Nid;
@@ -29,42 +28,6 @@ use std::hash::{Hash, Hasher};
use std::path::Path;
use std::time::{SystemTime, UNIX_EPOCH};
-pub fn print_cert(cert: &Certificate) {
- println!(
- "{}
-Issuer: {}
-Gültigkeit: Gültig von: {} bis: {}
-SHA-1-Fingerprint: {}
-SHA-256-Fingerprint: {}
-Subject-Key-Id: {}
-Authority-Key-Id: {}",
- style(format!("Name: {}", cert.name()))
- .bold()
- .underlined(),
- cert.issuer(),
- if cert.is_valid_not_before(&SystemTime::now()) {
- style(cert.not_before().to_string())
- } else {
- style(cert.not_before().to_string()).red()
- },
- if cert.is_valid_not_after(&SystemTime::now()) {
- style(cert.not_after().to_string())
- } else {
- style(cert.not_after().to_string()).red()
- },
- cert.fingerprint().sha1,
- cert.fingerprint().sha256,
- cert.subject_key_id(),
- cert.authority_key_id(),
- );
- if !cert.dns_names().is_empty() {
- println!(
- "DNS Names: {}",
- style(cert.dns_names().join(", "))
- );
- }
-}
-
pub fn hex_encode>(s: T) -> String {
s.as_ref()
.iter()
diff --git a/src/main.rs b/src/main.rs
index 6b391a1..987b1b5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -20,12 +20,13 @@
mod cli;
use crate::cli::{Cli, SubCommand};
+use cert_tools::{Certificate, Chain, PrivateKey};
use clap::Parser;
use console::style;
use itertools::Itertools;
use std::cmp::Ordering;
use std::path::Path;
-use cert_tools::{print_cert, Chain, PrivateKey};
+use std::time::SystemTime;
fn main() -> Result<(), ()> {
let cli = Cli::parse();
@@ -150,3 +151,39 @@ fn main() -> Result<(), ()> {
}
Ok(())
}
+
+pub fn print_cert(cert: &Certificate) {
+ println!(
+ "{}
+Issuer: {}
+Gültigkeit: Gültig von: {} bis: {}
+SHA-1-Fingerprint: {}
+SHA-256-Fingerprint: {}
+Subject-Key-Id: {}
+Authority-Key-Id: {}",
+ style(format!("Name: {}", cert.name()))
+ .bold()
+ .underlined(),
+ cert.issuer(),
+ if cert.is_valid_not_before(&SystemTime::now()) {
+ style(cert.not_before().to_string())
+ } else {
+ style(cert.not_before().to_string()).red()
+ },
+ if cert.is_valid_not_after(&SystemTime::now()) {
+ style(cert.not_after().to_string())
+ } else {
+ style(cert.not_after().to_string()).red()
+ },
+ cert.fingerprint().sha1,
+ cert.fingerprint().sha256,
+ cert.subject_key_id(),
+ cert.authority_key_id(),
+ );
+ if !cert.dns_names().is_empty() {
+ println!(
+ "DNS Names: {}",
+ style(cert.dns_names().join(", "))
+ );
+ }
+}