Skip to content

Commit

Permalink
Merge pull request #10 from djkormo/release-fix-2
Browse files Browse the repository at this point in the history
changing release date
  • Loading branch information
djkormo authored Dec 16, 2022
2 parents d20ef65 + fb8377c commit fea42f3
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 24 deletions.
3 changes: 0 additions & 3 deletions adcs/ntlm_certsrv.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,6 @@ func (s *NtlmCertsrv) RequestCertificate(csr string, template string) (AdcsRespo
log.Info("Body", "body", bodyString)
}


exp := regexp.MustCompile(`certnew.cer\?ReqID=([0-9]+)&`)
found := exp.FindStringSubmatch(bodyString)
certId := ""
Expand Down Expand Up @@ -333,12 +332,10 @@ func (s *NtlmCertsrv) obtainCaCertificate(certPage string, expectedContentType s
}
res1, err := s.httpClient.Do(req)


if os.Getenv("ENABLE_DEBUG") == "true" {
log.Info("obtainCaCertificate start", "res1", res1)
}


if err != nil {
log.Error(err, "ADCS Certserv error")
return "", err
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/nokia/adcs-issuer
go 1.17

require (

github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
github.com/fullsailor/pkcs7 v0.0.0-20190404230743-d7302db945fa
github.com/go-logr/logr v1.2.0
Expand Down Expand Up @@ -68,6 +67,7 @@ require (
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
k8s.io/apiextensions-apiserver v0.23.1 // indirect
k8s.io/component-base v0.23.1 // indirect
k8s.io/klog v1.0.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/kube-aggregator v0.23.1 // indirect
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
Expand Down
6 changes: 0 additions & 6 deletions issuers/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import (
//cmmeta "github.com/jetstack/cert-manager/pkg/apis/meta/v1"
//metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"


"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/fullsailor/pkcs7"
"github.com/go-logr/logr"
"github.com/nokia/adcs-issuer/adcs"
api "github.com/nokia/adcs-issuer/api/v1"
ctrl "sigs.k8s.io/controller-runtime"

)

type Issuer struct {
Expand Down Expand Up @@ -58,7 +56,6 @@ func (i *Issuer) Issue(ctx context.Context, ar *api.AdcsRequest) ([]byte, []byte
// New request
adcsResponseStatus, desc, id, err = i.certServ.RequestCertificate(string(ar.Spec.CSRPEM), i.AdcsTemplateName)


if log.V(5).Enabled() {
log.V(5).Info("new adcsRequest", "adcs response status", adcsResponseStatus, "desc", desc, "id", id)

Expand Down Expand Up @@ -109,15 +106,13 @@ func (i *Issuer) Issue(ctx context.Context, ar *api.AdcsRequest) ([]byte, []byte
return nil, nil, err
}


if log.V(4).Enabled() {
s := string(cert)
log.V(4).Info("parsed certificate", "certificate", s)
}

// log.V(4).Info("will return cert", "cert", cert)


return cert, ca, nil

}
Expand All @@ -129,7 +124,6 @@ func (i *Issuer) Issue(ctx context.Context, ar *api.AdcsRequest) ([]byte, []byte

func parseCaCert(cc []byte, log logr.Logger) ([]byte, error) {


// decode Pem from certificate into block
block, rest := pem.Decode([]byte(cc))
if block == nil {
Expand Down
6 changes: 0 additions & 6 deletions issuers/issuer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

var (
log = ctrl.Log.WithName("issuer_test")

)

// TODO: provide proper PKCS7 certificates for testing.
Expand All @@ -30,7 +29,6 @@ func TestParsingCaCertShouldReturnX509(t *testing.T) {

parsedCaCert, err := parseCaCert(pkcs7Pem, log)


// assert
assert.NoError(t, err)
assert.Equal(t, validX509Certificate, parsedCaCert)
Expand All @@ -45,7 +43,6 @@ func TestIncorrectFormatPkcs(t *testing.T) {

ca, err := parseCaCert(incorrectPKCS7Cert, log)


// assert
assert.EqualError(t, err, "parsing PKCS7: ber2der: BER tag length is more than available data")
assert.Nil(t, ca, "expecting ca to be empty")
Expand All @@ -72,7 +69,6 @@ func TestIncorrectCertFormat(t *testing.T) {

ca, err := parseCaCert(incorrectCertFormat, log)


// assert
assert.Error(t, err)
assert.EqualError(t, err, "error decoding the pem block")
Expand All @@ -91,7 +87,6 @@ func TestParseCaCertCorrectPKCS7(t *testing.T) {

ca, err := parseCaCert(rawPkcs7, log)


// assert
assert.NoError(t, err)
assert.Equal(t, cfssOutputX509, ca)
Expand All @@ -106,7 +101,6 @@ func TestCorrectX509Cert(t *testing.T) {

parsedCaCert, err := parseCaCert(x509, log)


// assert
assert.NoError(t, err)
assert.Equal(t, x509, parsedCaCert)
Expand Down
10 changes: 2 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/nokia/adcs-issuer/controllers"
"github.com/nokia/adcs-issuer/healthcheck"
"github.com/nokia/adcs-issuer/issuers"

zaplogfmt "github.com/sykesm/zap-logfmt"
uzap "go.uber.org/zap"
"go.uber.org/zap/zapcore"
Expand All @@ -36,6 +37,7 @@ import (
"k8s.io/utils/clock"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
// +kubebuilder:scaffold:imports
)

Expand Down Expand Up @@ -88,12 +90,7 @@ func main() {
}
opts.BindFlags(flag.CommandLine)


flag.Parse()
log := klogr.New()
ctrl.SetLogger(log)
// flag.Parse()


// based on https://sdk.operatorframework.io/docs/building-operators/golang/references/logging/

Expand All @@ -104,8 +101,6 @@ func main() {
}
logfmtEncoder := zaplogfmt.NewEncoder(configLog)

//ctrl.SetLogger(zap.New(zap.UseFlagOptions(&opts)))

// Construct a new logr.logger.
logger := zap.New(zap.UseDevMode(false), zap.WriteTo(os.Stdout), zap.Encoder(logfmtEncoder))
ctrl.SetLogger(logger)
Expand All @@ -114,7 +109,6 @@ func main() {

setupLog.Info("Starting ADCS Issuer", "version", version, "build time", buildTime)


mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsAddr,
Expand Down

0 comments on commit fea42f3

Please sign in to comment.