@@ -20,7 +20,6 @@ use crate::errors::{Result, SigstoreError};
2020
2121use async_trait:: async_trait;
2222use cached:: proc_macro:: cached;
23- use olpc_cjson:: CanonicalFormatter ;
2423use serde:: Serialize ;
2524use sha2:: { Digest , Sha256 } ;
2625use tracing:: { debug, error} ;
@@ -105,12 +104,13 @@ impl<'a> PullSettings<'a> {
105104 // Because of that the method will return the '0' value when something goes
106105 // wrong during the serialization operation. This is very unlikely to happen
107106 pub fn hash ( & self ) -> String {
108- let mut buf = Vec :: new ( ) ;
109- let mut ser = serde_json:: Serializer :: with_formatter ( & mut buf, CanonicalFormatter :: new ( ) ) ;
110- if let Err ( e) = self . serialize ( & mut ser) {
111- error ! ( err=?e, settings=?self , "Cannot perform canonical serialization" ) ;
112- return "0" . to_string ( ) ;
113- }
107+ let buf = match serde_json_canonicalizer:: to_vec ( self ) {
108+ Ok ( vec) => vec,
109+ Err ( e) => {
110+ error ! ( err=?e, settings=?self , "Cannot perform canonical serialization" ) ;
111+ return "0" . to_string ( ) ;
112+ }
113+ } ;
114114
115115 let mut hasher = Sha256 :: new ( ) ;
116116 hasher. update ( & buf) ;
@@ -196,12 +196,13 @@ impl PullManifestSettings {
196196 // Because of that the method will return the '0' value when something goes
197197 // wrong during the serialization operation. This is very unlikely to happen
198198 pub fn hash ( & self ) -> String {
199- let mut buf = Vec :: new ( ) ;
200- let mut ser = serde_json:: Serializer :: with_formatter ( & mut buf, CanonicalFormatter :: new ( ) ) ;
201- if let Err ( e) = self . serialize ( & mut ser) {
202- error ! ( err=?e, settings=?self , "Cannot perform canonical serialization" ) ;
203- return "0" . to_string ( ) ;
204- }
199+ let buf = match serde_json_canonicalizer:: to_vec ( self ) {
200+ Ok ( vec) => vec,
201+ Err ( e) => {
202+ error ! ( err=?e, settings=?self , "Cannot perform canonical serialization" ) ;
203+ return "0" . to_string ( ) ;
204+ }
205+ } ;
205206
206207 let mut hasher = Sha256 :: new ( ) ;
207208 hasher. update ( & buf) ;
0 commit comments