go-xmlsec icon indicating copy to clipboard operation
go-xmlsec copied to clipboard

Can not build with GOARCH=arm64

Open Harikesh00 opened this issue 2 years ago • 0 comments

We are building the go binary using MakeFile which runs the below command present in the .Dockerfile I want to build on GOARCH=arm64

RUN GOARCH=arm64 GOOS=linux go build -mod vendor -tags "static netgo" -ldflags '-s -extldflags "-static"' -o bin/upgrade ./cmd/upgrade && \
        GOARCH=arm64 GOOS=linux go build -mod vendor -tags "static netgo" -ldflags '-s -extldflags "-static"' -o bin/onboard ./cmd/onboarding && \
        GOARCH=arm64 GOOS=linux go build -mod vendor -tags "static netgo" -ldflags '-s -extldflags "-static"' -o bin/restserver ./cmd/restserver/main.go && \
        GOARCH=arm64 GOOS=linux go build -mod vendor -tags "static netgo" -ldflags '-s -extldflags "-static"' -o bin/restlambda ./cmd/restlambda/main.go && \
  cd cmd/upgrade && rice append --exec ../../bin/upgrade

but I getting the error

pkg/saml/sign_static.go:31:23: undefined: xmlsec.Sign
pkg/saml/sign_static.go:31:112: undefined: xmlsec.SignatureOptions
pkg/saml/sign_static.go:32:19: undefined: xmlsec.XMLIDOption

sign_static.go file contains the below code

func sign(xml string, privateKeyPath string, id string) (string, error) {

	var (
		output, key []byte
		err         error
	)
	key, err = ioutil.ReadFile(privateKeyPath)
	if err != nil {
		return "", errors.New(err.Error())
	}
	output, err = xmlsec.Sign(key, []byte(fmt.Sprintf("<?xml version='1.0' encoding='UTF-8'?>\n%s", xml)), xmlsec.SignatureOptions{
		XMLID: []xmlsec.XMLIDOption{
			{
				ElementName:      "Response",
				ElementNamespace: "urn:oasis:names:tc:SAML:2.0:protocol",
				AttributeName:    "ID",
			},
		},
	})

	if err != nil {
		return "", errors.New(err.Error() + " : " + string(output))
	}

	return string(output), nil
}

It works with the GOARCH=amd64 but with GOARCH=arm64 it gave an error. I want help here, is this really an issue with the library or am I doing something wrong?

Harikesh00 avatar Nov 01 '23 12:11 Harikesh00