Skip to content

Commit 8453978

Browse files
mergify[bot]kruskallmichalpristas
authored
feat: generate a subject key identifier when creating a certificate (#6379) (#8329)
* feat: generate a subject key identifier when creating a certificate If a subject key id is omitted, go will generate one using sha1. This is described as method 1 in RFC 5280 Section 4.2.1.2. When sha1 is not available (e.g. fips only mode) this method will panic. Update the code to explicitly pass a subject key id to avoid calling sha1 functions. The new SubjectKeyId is generated using method 1 in RFC 7093 Section 2 which takes 160-bits of the SHA-256 hash. * Update ca.go --------- (cherry picked from commit 2d22996) Co-authored-by: kruskall <[email protected]> Co-authored-by: Michal Pristas <[email protected]>
1 parent 61cd38b commit 8453978

File tree

1 file changed

+2
-0
lines changed
  • internal/pkg/core/authority

1 file changed

+2
-0
lines changed

internal/pkg/core/authority/ca.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ func (c *CertificateAuthority) GeneratePairWithName(name string) (*Pair, error)
140140
privateKey, _ := rsa.GenerateKey(rand.Reader, 2048)
141141
publicKey := &privateKey.PublicKey
142142

143+
certTemplate.SubjectKeyId = generateSubjectKeyID(publicKey)
144+
143145
// Sign the certificate
144146
certBytes, err := x509.CreateCertificate(rand.Reader, certTemplate, c.caCert, publicKey, c.privateKey)
145147
if err != nil {

0 commit comments

Comments
 (0)