Skip to content

Commit

Permalink
Merge pull request #77 from Venafi/arm-support
Browse files Browse the repository at this point in the history
Adding ability to generate ARM binaries
  • Loading branch information
luispresuelVenafi authored Mar 19, 2022
2 parents 908c931 + 40bc64b commit 6ce13f8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,22 @@ build:
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags '-s -w -extldflags "-static"' -a -o $(PLUGIN_DIR)/linux/$(PLUGIN_NAME)_$(VERSION) || exit 1
env CGO_ENABLED=0 GOOS=linux GOARCH=386 go build -ldflags '-s -w -extldflags "-static"' -a -o $(PLUGIN_DIR)/linux86/$(PLUGIN_NAME)_$(VERSION) || exit 1
env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags '-s -w -extldflags "-static"' -a -o $(PLUGIN_DIR)/darwin/$(PLUGIN_NAME)_$(VERSION) || exit 1
env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags '-s -w -extldflags "-static"' -a -o $(PLUGIN_DIR)/darwin_arm/$(PLUGIN_NAME)_$(VERSION) || exit 1
#Build with debugging options, use it for remote debugging. Comment the above line
#env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build '-gcflags="all=-N -l" -extldflags "-static"' -a -o $(PLUGIN_DIR)/darwin/$(PLUGIN_NAME)_$(VERSION) || exit 1
env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags '-s -w -extldflags "-static"' -a -o $(PLUGIN_DIR)/windows/$(PLUGIN_NAME)_$(VERSION).exe || exit 1
env CGO_ENABLED=0 GOOS=windows GOARCH=386 go build -ldflags '-s -w -extldflags "-static"' -a -o $(PLUGIN_DIR)/windows86/$(PLUGIN_NAME)_$(VERSION).exe || exit 1
chmod +x $(PLUGIN_DIR)/*

compress:
$(foreach var,linux linux86 darwin windows windows86,cp LICENSE $(PLUGIN_DIR)/$(var);)
$(foreach var,linux linux86 darwin windows windows86,cp README.md $(PLUGIN_DIR)/$(var);)
$(foreach var,linux linux86 darwin darwin_arm windows windows86,cp LICENSE $(PLUGIN_DIR)/$(var);)
$(foreach var,linux linux86 darwin darwin_arm windows windows86,cp README.md $(PLUGIN_DIR)/$(var);)
mkdir -p $(DIST_DIR)
rm -f $(DIST_DIR)/*
zip -j "$(DIST_DIR)/${PLUGIN_NAME}_$(ZIP_VERSION)_linux_amd64.zip" $(PLUGIN_DIR)/linux/* || exit 1
zip -j "$(DIST_DIR)/${PLUGIN_NAME}_$(ZIP_VERSION)_linux_386.zip" $(PLUGIN_DIR)/linux86/* || exit 1
zip -j "$(DIST_DIR)/${PLUGIN_NAME}_$(ZIP_VERSION)_darwin_amd64.zip" $(PLUGIN_DIR)/darwin/* || exit 1
zip -j "$(DIST_DIR)/${PLUGIN_NAME}_$(ZIP_VERSION)_darwin_arm64.zip" $(PLUGIN_DIR)/darwin_arm/* || exit 1
zip -j "$(DIST_DIR)/${PLUGIN_NAME}_$(ZIP_VERSION)_windows_amd64.zip" $(PLUGIN_DIR)/windows/* || exit 1
zip -j "$(DIST_DIR)/${PLUGIN_NAME}_$(ZIP_VERSION)_windows_386.zip" $(PLUGIN_DIR)/windows86/* || exit 1

Expand Down
1 change: 1 addition & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//go:build tools
// +build tools

package main
Expand Down
4 changes: 2 additions & 2 deletions venafi/resource_venafi_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ func AsPKCS12(certificate string, privateKey string, chain []string, keyPassword
return nil, fmt.Errorf("missing private key PEM")
}
var privDER []byte
if x509.IsEncryptedPEMBlock(p) {
privDER, err = x509.DecryptPEMBlock(p, []byte(keyPassword))
if util.X509IsEncryptedPEMBlock(p) {
privDER, err = util.X509DecryptPEMBlock(p, []byte(keyPassword))
if err != nil {
return nil, fmt.Errorf("private key PEM decryption error: %s", err)
}
Expand Down
5 changes: 2 additions & 3 deletions venafi/util.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package venafi

import (
"crypto/x509"
"encoding/pem"
"fmt"
"github.com/Venafi/vcert/v4"
Expand Down Expand Up @@ -103,8 +102,8 @@ func getPrivateKey(keyBytes []byte, passphrase string) ([]byte, error) {
}

var err error
if x509.IsEncryptedPEMBlock(pemBlock) {
keyBytes, err = x509.DecryptPEMBlock(pemBlock, []byte(passphrase))
if util.X509IsEncryptedPEMBlock(pemBlock) {
keyBytes, err = util.X509DecryptPEMBlock(pemBlock, []byte(passphrase))
if err != nil {
return nil, errors.Wrap(err, "private key is encrypted, but could not decrypt it")
}
Expand Down

0 comments on commit 6ce13f8

Please sign in to comment.