File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -413,24 +413,23 @@ func (k *CAPIKMS) getCertContext(req *apiv1.LoadCertificateRequest) (*windows.Ce
413
413
// TODO: Replace this search with a CERT_ID + CERT_ISSUER_SERIAL_NUMBER search instead
414
414
// https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/ns-wincrypt-cert_id
415
415
// https://learn.microsoft.com/en-us/windows/win32/api/wincrypt/ns-wincrypt-cert_issuer_serial_number
416
- var serialBytes [] byte
416
+ var bi * big. Int
417
417
if strings .HasPrefix (serialNumber , "0x" ) {
418
- serialNumber = strings .TrimPrefix (serialNumber , "0x" )
419
- serialNumber = strings .TrimPrefix (serialNumber , "00" ) // Comparison fails if leading 00 is not removed
420
- serialBytes , err = hex .DecodeString (serialNumber )
418
+ serialBytes , err := hex .DecodeString (strings .TrimPrefix (serialNumber , "0x" ))
421
419
if err != nil {
422
420
return nil , fmt .Errorf ("invalid hex format for %s: %w" , SerialNumberArg , err )
423
421
}
422
+
423
+ bi = new (big.Int ).SetBytes (serialBytes )
424
424
} else {
425
425
bi := new (big.Int )
426
426
bi , ok := bi .SetString (serialNumber , 10 )
427
427
if ! ok {
428
428
return nil , fmt .Errorf ("invalid %s - must be in hex or integer format" , SerialNumberArg )
429
429
}
430
- serialBytes = bi .Bytes ()
431
430
}
432
431
433
- if bytes . Equal ( x509Cert .SerialNumber .Bytes (), serialBytes ) {
432
+ if x509Cert .SerialNumber .Cmp ( bi ) == 0 {
434
433
return handle , nil
435
434
}
436
435
case len (subjectCN ) > 0 :
You can’t perform that action at this time.
0 commit comments