Skip to content

Commit 9876502

Browse files
authored
Merge pull request #314 from cloudflare/nicky/goreleaser-pkcs11
2 parents 7106a15 + ee2afff commit 9876502

File tree

5 files changed

+59
-2
lines changed

5 files changed

+59
-2
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: goreleaser
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
goreleaser:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
- name: Set up Go
20+
uses: actions/setup-go@v3
21+
- run: make release-github
22+
env:
23+
GORELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/snapshot.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Image snapshots
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v2
11+
- run: make snapshot
12+
- name: Archive snapshot artifacts
13+
uses: actions/upload-artifact@v3
14+
with:
15+
name: binaries
16+
path: dist/*

.goreleaser.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ builds:
1414
goarch:
1515
- amd64
1616
main: ./cmd/gokeyless
17+
flags:
18+
- -tags=pkcs11
1719
ldflags:
1820
- -s -w -X main.version={{.Version}}
1921
- id: gokeyless-linux
@@ -23,6 +25,8 @@ builds:
2325
goarch:
2426
- amd64
2527
main: ./cmd/gokeyless
28+
flags:
29+
- -tags=pkcs11
2630
ldflags:
2731
- -s -w -X main.version={{.Version}}
2832
- -linkmode external -extldflags "-static"

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,11 @@ release-github:
121121
--env GORELEASER_GITHUB_TOKEN \
122122
neilotoole/xcgo:latest goreleaser --rm-dist
123123

124+
125+
.PHONY: snapshot
126+
snapshot:
127+
docker run --rm --privileged -v $(PWD):/go/tmp \
128+
-v /var/run/docker.sock:/var/run/docker.sock \
129+
-w /go/tmp \
130+
neilotoole/xcgo:latest goreleaser --snapshot --rm-dist
131+

server/pkcs11.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
//go:build pkcs11 && cgo
12
// +build pkcs11,cgo
23

34
package server
45

56
import (
67
"crypto"
8+
"fmt"
79

810
"github.com/cloudflare/gokeyless/internal/rfc7512"
911
)
@@ -15,10 +17,14 @@ func DefaultLoadURI(uri string) (crypto.Signer, error) {
1517
// as waiting for network to be up.
1618
pk11uri, err := rfc7512.ParsePKCS11URI(uri)
1719
if err != nil {
18-
return nil, err
20+
return nil, fmt.Errorf("failed to parse pkcs11: %w", err)
1921
}
2022

21-
return rfc7512.LoadPKCS11Signer(pk11uri)
23+
signer, err := rfc7512.LoadPKCS11Signer(pk11uri)
24+
if err != nil {
25+
return nil, fmt.Errorf("failed to load pkcs11: %w", err)
26+
}
27+
return signer, nil
2228
}
2329

2430
func loadPKCS11URI(uri string) (crypto.Signer, error) {

0 commit comments

Comments
 (0)