File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -80,10 +80,13 @@ impl GeneratePkcs12 {
8080
8181impl CertInput {
8282 pub fn read ( & self ) -> Result < Vec < X509 > , snafu:: Whatever > {
83+ let read_file_fn = |path| {
84+ fs:: read ( path) . with_whatever_context ( |_| format ! ( "failed to read file from {self:?}" ) )
85+ } ;
86+
8387 match self {
8488 CertInput :: Pem ( path) => {
85- let file_contents = fs:: read ( path)
86- . with_whatever_context ( |_| format ! ( "failed to read file from {self:?}" ) ) ?;
89+ let file_contents = read_file_fn ( path) ?;
8790
8891 let certs = parse_pem_contents ( & file_contents) . with_whatever_context ( |_| {
8992 format ! (
@@ -99,8 +102,7 @@ impl CertInput {
99102 Ok ( certs)
100103 }
101104 CertInput :: Pkcs12 ( Pkcs12Source { path, password } ) => {
102- let file_contents = fs:: read ( path)
103- . with_whatever_context ( |_| format ! ( "failed to read file from {self:?}" ) ) ?;
105+ let file_contents = read_file_fn ( path) ?;
104106
105107 parse_pkcs12_file_workaround ( & file_contents, password)
106108 }
You can’t perform that action at this time.
0 commit comments