File tree Expand file tree Collapse file tree
rust/truststore-merger/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11use std:: { fs, path:: PathBuf } ;
22
3- use anyhow:: Context ;
3+ use anyhow:: { Context , ensure } ;
44use clap:: Parser ;
55use openssl:: x509:: X509 ;
66
@@ -68,12 +68,21 @@ impl CertInput {
6868 fs:: read ( self . path ( ) ) . with_context ( || format ! ( "failed to read file from {self:?}" ) ) ?;
6969
7070 match self {
71- CertInput :: Pem ( _) => parse_pem_contents ( & file_contents) . with_context ( || {
72- format ! (
73- "failed to parse PEM contents from {path:?}" ,
71+ CertInput :: Pem ( _) => {
72+ let certs = parse_pem_contents ( & file_contents) . with_context ( || {
73+ format ! (
74+ "failed to parse PEM contents from {path:?}" ,
75+ path = self . path( )
76+ )
77+ } ) ?;
78+ ensure ! (
79+ !certs. is_empty( ) ,
80+ "The PEM file {path:?} contained no certificates" ,
7481 path = self . path( )
75- )
76- } ) ,
82+ ) ;
83+
84+ Ok ( certs)
85+ }
7786 CertInput :: Pkcs12 ( Pkcs12Source { password, .. } ) => {
7887 parse_pkcs12_file_workaround ( & file_contents, password)
7988 }
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ pub fn main() -> anyhow::Result<()> {
4545
4646 let mut certificates = HashMap :: < Vec < u8 > , X509 > :: new ( ) ;
4747 for ( source, certificates_list) in certificate_sources. into_iter ( ) {
48+ info ! ( ?source, "Importing certificates" ) ;
49+
4850 for certificate in certificates_list {
4951 let sha256 = certificate. sha256_digest ( ) ?;
5052
You can’t perform that action at this time.
0 commit comments