@@ -142,7 +142,9 @@ const SELF_SIGNED_INT: u8 = 2;
142142
143143/// A function to generate C509 certificate.
144144fn generate (
145- file : & PathBuf , output : Option < PathBuf > , private_key : Option < & PrivateKey > ,
145+ file : & PathBuf ,
146+ output : Option < PathBuf > ,
147+ private_key : Option < & PrivateKey > ,
146148 key_type : Option < String > ,
147149) -> anyhow:: Result < ( ) > {
148150 let data = fs:: read_to_string ( file) ?;
@@ -209,7 +211,10 @@ fn generate(
209211}
210212
211213/// Write a data to a file given an output path.
212- fn write_to_output_file ( output : PathBuf , data : & [ u8 ] ) -> anyhow:: Result < ( ) > {
214+ fn write_to_output_file (
215+ output : PathBuf ,
216+ data : & [ u8 ] ,
217+ ) -> anyhow:: Result < ( ) > {
213218 let mut file = File :: create ( output) . map_err ( |e| anyhow:: anyhow!( e) ) ?;
214219 file. write_all ( data) . map_err ( |e| anyhow:: anyhow!( e) ) ?;
215220 Ok ( ( ) )
@@ -219,7 +224,9 @@ fn write_to_output_file(output: PathBuf, data: &[u8]) -> anyhow::Result<()> {
219224/// If self-signed is true, issuer is the same as subject.
220225/// Otherwise, issuer must be present.
221226fn determine_issuer (
222- self_signed : bool , issuer : Option < Vec < Attribute > > , subject : Vec < Attribute > ,
227+ self_signed : bool ,
228+ issuer : Option < Vec < Attribute > > ,
229+ subject : Vec < Attribute > ,
223230) -> anyhow:: Result < Vec < Attribute > > {
224231 if self_signed {
225232 Ok ( subject)
@@ -230,7 +237,8 @@ fn determine_issuer(
230237
231238/// Validate the certificate type.
232239fn validate_certificate_type (
233- self_signed : bool , certificate_type : Option < u8 > ,
240+ self_signed : bool ,
241+ certificate_type : Option < u8 > ,
234242) -> anyhow:: Result < ( ) > {
235243 if self_signed && certificate_type. unwrap_or ( SELF_SIGNED_INT ) != SELF_SIGNED_INT {
236244 return Err ( anyhow:: anyhow!(
@@ -260,7 +268,10 @@ fn get_key_type(key_type: Option<String>) -> anyhow::Result<(Oid<'static>, Optio
260268}
261269
262270/// Parse date string to u64.
263- fn parse_or_default_date ( date_option : Option < String > , default : u64 ) -> Result < u64 , anyhow:: Error > {
271+ fn parse_or_default_date (
272+ date_option : Option < String > ,
273+ default : u64 ,
274+ ) -> Result < u64 , anyhow:: Error > {
264275 match date_option {
265276 Some ( date) => {
266277 DateTime :: parse_from_rfc3339 ( & date)
@@ -284,7 +295,10 @@ fn parse_serial_number(serial_number: Option<UnwrappedBigUint>) -> UnwrappedBigU
284295// -------------------verify-----------------------
285296
286297/// Verify the signature of the certificate given public key file path.
287- fn verify ( file : & PathBuf , public_key : PathBuf ) -> anyhow:: Result < ( ) > {
298+ fn verify (
299+ file : & PathBuf ,
300+ public_key : PathBuf ,
301+ ) -> anyhow:: Result < ( ) > {
288302 let cert = fs:: read ( file) ?;
289303 let pk = PublicKey :: from_file ( public_key) ?;
290304 match c509_certificate:: verify ( & cert, & pk) {
@@ -297,7 +311,10 @@ fn verify(file: &PathBuf, public_key: PathBuf) -> anyhow::Result<()> {
297311// -------------------decode-----------------------
298312
299313/// Decode the certificate to JSON.
300- fn decode ( file : & PathBuf , output : Option < PathBuf > ) -> anyhow:: Result < ( ) > {
314+ fn decode (
315+ file : & PathBuf ,
316+ output : Option < PathBuf > ,
317+ ) -> anyhow:: Result < ( ) > {
301318 let cert = fs:: read ( file) ?;
302319 let mut d = minicbor:: Decoder :: new ( & cert) ;
303320 let c509 = c509_certificate:: c509:: C509 :: decode ( & mut d, & mut ( ) ) ?;
0 commit comments