Merge pull request #165 from munnerz/fix-panic

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

Fix panic in ACME issuer setup

**What this PR does / why we need it**:

Fix a panic in the ACME issuer registration flow

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes #

Closes #164 

**Release note**:

```release-note
Fix panic if the secret named in an ACME issuer exists but contains invalid data (or no data)
```
This commit is contained in:
jetstack-bot 2017-10-26 21:55:58 +01:00 committed by GitHub
commit 3b3ad36c20

View File

@ -13,6 +13,7 @@ import (
"github.com/golang/glog"
"github.com/jetstack-experimental/cert-manager/pkg/apis/certmanager/v1alpha1"
"github.com/jetstack-experimental/cert-manager/pkg/util/errors"
"github.com/jetstack-experimental/cert-manager/pkg/util/kube"
"github.com/jetstack-experimental/cert-manager/pkg/util/pki"
)
@ -33,7 +34,7 @@ const (
func (a *Acme) Setup(ctx context.Context) error {
glog.V(4).Infof("%s: getting acme account private key '%s/%s'", a.issuer.GetObjectMeta().Name, a.resourceNamespace, a.issuer.GetSpec().ACME.PrivateKey.Name)
cl, err := a.acmeClient()
if k8sErrors.IsNotFound(err) {
if k8sErrors.IsNotFound(err) || errors.IsInvalidData(err) {
glog.V(4).Infof("%s: generating acme account private key '%s/%s'", a.issuer.GetObjectMeta().Name, a.resourceNamespace, a.issuer.GetSpec().ACME.PrivateKey.Name)
var accountPrivKey *rsa.PrivateKey
accountPrivKey, err = a.createAccountPrivateKey()
@ -51,6 +52,7 @@ func (a *Acme) Setup(ctx context.Context) error {
s := messageAccountVerificationFailed + err.Error()
glog.V(4).Infof("%s: %s", a.issuer.GetObjectMeta().Name, s)
a.recorder.Event(a.issuer, v1.EventTypeWarning, errorAccountVerificationFailed, s)
return err
}
glog.V(4).Infof("Verifying ")