@@ -419,6 +419,12 @@ func (h *apiHandlerv2) register(w http.ResponseWriter, r *http.Request) {
419
419
http .Error (w , http .StatusText (http .StatusBadRequest ), http .StatusBadRequest )
420
420
return
421
421
}
422
+ if len (b .SenderCertHash ) == 0 {
423
+ log .Printf ("no SenderCertHash in AuthContainer" )
424
+ http .Error (w , http .StatusText (http .StatusUnauthorized ), http .StatusUnauthorized )
425
+ return
426
+ }
427
+
422
428
onBoardCertDecoded , err := base64 .StdEncoding .DecodeString (string (b .GetSenderCert ()))
423
429
if err != nil {
424
430
log .Printf ("error decoding SenderCert: %v" , err )
@@ -431,6 +437,23 @@ func (h *apiHandlerv2) register(w http.ResponseWriter, r *http.Request) {
431
437
http .Error (w , http .StatusText (http .StatusBadRequest ), http .StatusBadRequest )
432
438
return
433
439
}
440
+
441
+ // at least one of the certs should be the onboarding cert
442
+ for _ , cert := range onboardCert {
443
+ payload := b .ProtectedPayload .GetPayload ()
444
+ hashedPayload := sha256 .Sum256 (payload )
445
+ err = verifySignature (b .SignatureHash , hashedPayload [:], cert )
446
+ if err == nil {
447
+ log .Printf ("signature verification passed" )
448
+ break
449
+ }
450
+ }
451
+ if err != nil {
452
+ log .Printf ("signature verification failed: %v" , err )
453
+ http .Error (w , http .StatusText (http .StatusUnauthorized ), http .StatusUnauthorized )
454
+ return
455
+ }
456
+
434
457
if len (onboardCert ) == 0 {
435
458
log .Println ("no certificates parsed from SenderCert" )
436
459
http .Error (w , http .StatusText (http .StatusBadRequest ), http .StatusBadRequest )
0 commit comments