@@ -106,31 +106,33 @@ func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc TrillianC
106106 return nil , err
107107 }
108108
109- var att []byte
110- var fetchErr error
111- attKey := eimpl .AttestationKey ()
112- // if we're given a key by the type logic, let's try that first
113- if attKey != "" {
114- att , fetchErr = storageClient .FetchAttestation (ctx , attKey )
115- if fetchErr != nil {
116- log .ContextLogger (ctx ).Errorf ("error fetching attestation by key, trying by UUID: %s %w" , attKey , fetchErr )
117- }
118- }
119- // if looking up by key failed or we weren't able to generate a key, try looking up by uuid
120- if attKey == "" || fetchErr != nil {
121- activeTree := fmt .Sprintf ("%x" , tc .logID )
122- entryIDstruct , err := sharding .CreateEntryIDFromParts (activeTree , uuid )
123- if err != nil {
124- return nil , fmt .Errorf ("error creating EntryID from active treeID %v and uuid %v: %w" , activeTree , uuid , err )
109+ if entryWithAtt , ok := eimpl .(types.EntryWithAttestationImpl ); ok {
110+ var att []byte
111+ var fetchErr error
112+ attKey := entryWithAtt .AttestationKey ()
113+ // if we're given a key by the type logic, let's try that first
114+ if attKey != "" {
115+ att , fetchErr = storageClient .FetchAttestation (ctx , attKey )
116+ if fetchErr != nil {
117+ log .ContextLogger (ctx ).Errorf ("error fetching attestation by key, trying by UUID: %s %w" , attKey , fetchErr )
118+ }
125119 }
126- att , fetchErr = storageClient .FetchAttestation (ctx , entryIDstruct .UUID )
127- if fetchErr != nil {
128- log .ContextLogger (ctx ).Errorf ("error fetching attestation by uuid: %s %v" , entryIDstruct .UUID , fetchErr )
120+ // if looking up by key failed or we weren't able to generate a key, try looking up by uuid
121+ if attKey == "" || fetchErr != nil {
122+ activeTree := fmt .Sprintf ("%x" , tc .logID )
123+ entryIDstruct , err := sharding .CreateEntryIDFromParts (activeTree , uuid )
124+ if err != nil {
125+ return nil , fmt .Errorf ("error creating EntryID from active treeID %v and uuid %v: %w" , activeTree , uuid , err )
126+ }
127+ att , fetchErr = storageClient .FetchAttestation (ctx , entryIDstruct .UUID )
128+ if fetchErr != nil {
129+ log .ContextLogger (ctx ).Errorf ("error fetching attestation by uuid: %s %v" , entryIDstruct .UUID , fetchErr )
130+ }
129131 }
130- }
131- if fetchErr == nil {
132- logEntryAnon . Attestation = & models. LogEntryAnonAttestation {
133- Data : att ,
132+ if fetchErr == nil {
133+ logEntryAnon . Attestation = & models. LogEntryAnonAttestation {
134+ Data : att ,
135+ }
134136 }
135137 }
136138 }
@@ -250,20 +252,21 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl
250252 }
251253
252254 if viper .GetBool ("enable_attestation_storage" ) {
253-
254- go func () {
255- attKey , attVal := entry .AttestationKeyValue ()
256- if attVal == nil {
257- log .ContextLogger (ctx ).Infof ("no attestation for %s" , uuid )
258- return
259- }
260- if err := storeAttestation (context .Background (), attKey , attVal ); err != nil {
261- // entryIDstruct.UUID
262- log .ContextLogger (ctx ).Errorf ("error storing attestation: %s" , err )
255+ if entryWithAtt , ok := entry .(types.EntryWithAttestationImpl ); ok {
256+ attKey , attVal := entryWithAtt .AttestationKeyValue ()
257+ if attVal != nil {
258+ go func () {
259+ if err := storeAttestation (context .Background (), attKey , attVal ); err != nil {
260+ // entryIDstruct.UUID
261+ log .ContextLogger (ctx ).Errorf ("error storing attestation: %s" , err )
262+ } else {
263+ log .ContextLogger (ctx ).Infof ("stored attestation for uuid %s with filename %s" , entryIDstruct .UUID , attKey )
264+ }
265+ }()
263266 } else {
264- log .ContextLogger (ctx ).Infof ("stored attestation for uuid %s with filename %s " , entryIDstruct . UUID , attKey )
267+ log .ContextLogger (ctx ).Infof ("no attestation returned for %s " , uuid )
265268 }
266- }()
269+ }
267270 }
268271
269272 signature , err := signEntry (ctx , api .signer , logEntryAnon )
0 commit comments