-
Notifications
You must be signed in to change notification settings - Fork 77
Bug 1810036: Ensure service CA certs are created with unique serial numbers #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "crypto/rsa" | ||
| "crypto/x509" | ||
| "fmt" | ||
| "math/big" | ||
| "time" | ||
|
|
||
| corev1 "k8s.io/api/core/v1" | ||
|
|
@@ -192,6 +193,19 @@ func createIntermediateCACert(targetCACert, signingCACert *x509.Certificate, sig | |
| // Enable key identity chaining | ||
| template.AuthorityKeyId = signingCACert.SubjectKeyId | ||
|
|
||
| // Set a new serial number so that the intermediate CA cert is | ||
| // differentiated from the target CA cert. This ensures that a serving | ||
| // cert bundle that includes the issuing CA cert and an intermediate CA | ||
| // cert generated by this function - with the issuing CA cert as the | ||
| // target and the previous CA as the signer - will not result in | ||
| // SEC_ERROR_REUSED_ISSUER_AND_SERIAL when read by applications like curl. | ||
| serialGenerator := crypto.RandomSerialGenerator{} | ||
| serial, err := serialGenerator.Next(template) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("failed to find next serial number: %v", err) | ||
| } | ||
| template.SerialNumber = big.NewInt(serial) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need the same for the signing CA as well |
||
|
|
||
| // Update the expiry if necessary | ||
| if expiry != nil { | ||
| template.NotAfter = *expiry | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for the record: this is not about curl, curl itself would happily work if it was compiled with a different crypto backend than NSS (the crypto backend that Mozilla develops and uses in its software). https://tools.ietf.org/html/rfc5280#section-4.1.2.2 requires the serial number to be unique for each certificate signed by the CA (which this intermediate CA cert is), and NSS crypto works better when performing these checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't disagree, I was just pointing out the symptom that is being addressed by the change. The adherence to any given RFC varies according to implementation - golang doesn't care, but NSS does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, my only point was - curl is not a good example as it's usually compiled with OpenSSL backend in most distributions that I've seen, so you wouldn't be able to observe the symptoms.