Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ require (
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef // indirect
github.com/google/uuid v1.1.1
github.com/jteeuwen/go-bindata v3.0.8-0.20151023091102-a0ff2567cfb7+incompatible
github.com/openshift/api v0.0.0-20200121180347-3b42f2648b08
github.com/openshift/api v0.0.0-20200302180901-b4f75e525601
github.com/openshift/build-machinery-go v0.0.0-20200211121458-5e3d6e570160
github.com/openshift/client-go v0.0.0-20191216194936-57f413491e9e
github.com/openshift/library-go v0.0.0-20200113183004-f2ca9aafdf5a
github.com/openshift/client-go v0.0.0-20200116152001-92a2713fa240
github.com/openshift/library-go v0.0.0-20200306195801-d9c73bbbdd51
github.com/prometheus/client_golang v1.1.0
github.com/prometheus/common v0.6.0
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
go.uber.org/atomic v1.4.0 // indirect
k8s.io/api v0.17.1
k8s.io/apiextensions-apiserver v0.17.0
k8s.io/apimachinery v0.17.1
k8s.io/api v0.17.2
k8s.io/apiextensions-apiserver v0.17.1
k8s.io/apimachinery v0.17.2
k8s.io/client-go v0.17.1
k8s.io/component-base v0.17.1
k8s.io/klog v1.0.0
Expand Down
64 changes: 20 additions & 44 deletions go.sum

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions pkg/operator/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"crypto/rsa"
"crypto/x509"
"fmt"
"math/big"
"time"

corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -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.
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The 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
Expand Down
32 changes: 32 additions & 0 deletions pkg/operator/rotate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,3 +247,35 @@ func TestRotateSigningCA(t *testing.T) {
dnsName := oldServingCert.Certs[0].Subject.CommonName
util.CheckRotation(t, dnsName, oldCertPEM, oldKeyPEM, oldBundlePEM, newCertPEM, newKeyPEM, newBundlePEM)
}

// TestCreateIntermediateCACert checks that the intermediate CA cert
// created by signing a target CA cert supports identity key chaining
// and uses a serial number distinct from that of the target CA cert.
func TestCreateIntermediateCACert(t *testing.T) {
// Create the signing CA
signingCAConfig, err := crypto.MakeSelfSignedCAConfig("foo", SigningCertificateLifetimeInDays)
if err != nil {
t.Fatalf("error generating a new ca: %v", err)
}
signingCACert := signingCAConfig.Certs[0]

// Create the CA targeted for signing
targetCAConfig, err := crypto.MakeSelfSignedCAConfig("foo", SigningCertificateLifetimeInDays)
if err != nil {
t.Fatalf("error generating a new ca: %v", err)
}
targetCACert := targetCAConfig.Certs[0]

intermediateCACert, err := createIntermediateCACert(targetCACert, signingCACert, signingCAConfig.Key.(*rsa.PrivateKey), nil)
if err != nil {
t.Fatalf("Failed to create intermediate CA cert: %v", err)
}

if bytes.Compare(intermediateCACert.AuthorityKeyId, signingCACert.SubjectKeyId) != 0 {
t.Fatalf("Expected intermediate CA cert AuthorityKeyId to match signing CA cert SubjectKeyId")
}

if intermediateCACert.SerialNumber.Cmp(targetCACert.SerialNumber) == 0 {
t.Fatalf("Expected intermediate CA cert serial number to differ from serial number of target CA cert")
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions vendor/github.com/gogo/protobuf/proto/encode.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions vendor/github.com/gogo/protobuf/proto/lib.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 41 additions & 30 deletions vendor/github.com/gogo/protobuf/proto/properties.go

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.

19 changes: 19 additions & 0 deletions vendor/github.com/gogo/protobuf/proto/table_merge.go

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.

6 changes: 4 additions & 2 deletions vendor/github.com/gogo/protobuf/proto/text.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading