Skip to content

fix: allow concurrent sign operations and serialize if not possible #14

fix: allow concurrent sign operations and serialize if not possible

fix: allow concurrent sign operations and serialize if not possible #14

Workflow file for this run

name: CI
on: [push, pull_request]
jobs:
hsm:
env:
HSM_SO_PIN: 1234
HSM_PIN: 1234
TOKEN_LABEL: 'test'
KEY_LABEL: 'test-key'
name: Build and Test
runs-on: ubuntu-latest
strategy:
matrix:
go: [ 1.24.x ]
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go }}
- name: Check out code
uses: actions/checkout@v2
- name: Generate Keys And Certs
run: |
mkdir keys-and-certs && cd keys-and-certs
mkdir certs private && echo 01 > serial
touch index.txt
cp /etc/ssl/openssl.cnf .
- name: Generate Private Key
working-directory: keys-and-certs
run: |
openssl genpkey -algorithm RSA -out private/key.pem
- name: Generate Server Certificate and Sign with Private Key
working-directory: keys-and-certs
run: |
openssl req -new -x509 -days 5 -config openssl.cnf -key private/key.pem -out certs/cert.pem -extensions v3_ca -addext "subjectAltName = DNS:localhost" -subj "/C=DE/ST=BW/L=Walldorf/O=OCM/CN=localhost" -sha256
- name: Client Certificate Generation
working-directory: keys-and-certs
run: |
mkdir client
mkdir client/private
mkdir client/certs
mkdir client/csr
openssl genpkey -algorithm RSA -out client/private/key.pem
openssl req -new -sha256 -config openssl.cnf -key client/private/key.pem -out client/csr/csr.pem -subj "/C=DE/ST=BW/L=Walldorf/O=OCM/CN=localhost"
openssl x509 -req -in client/csr/csr.pem -CA certs/cert.pem -CAkey private/key.pem -out client/certs/cert.pem -CAcreateserial -days 5 -sha256
- name: Setup SoftHSM
env:
SOFTHSM2_CONF: ${{ github.workspace }}/softhsm2.conf
id: softhsm
run: |
mkdir test_data
sudo apt-get update
sudo apt-get -y install libsofthsm2 gnutls-bin
# set output of lib to environment variable
softhsm2-util --init-token --slot 0 --free --label $TOKEN_LABEL --so-pin $HSM_SO_PIN --pin $HSM_PIN
p11tool --generate-privkey=rsa --login --set-pin=$HSM_PIN --label="$KEY_LABEL" "pkcs11:token=$TOKEN_LABEL" --outfile ${{ github.workspace }}/public_key.pem
- name: Build
run: make
- name: Run Tests
working-directory: ${{ github.workspace }}
env:
SOFTHSM2_CONF: ${{ github.workspace }}/softhsm2.conf
HSM_MODULE: ${{ steps.softhsm.outputs.SOFTHSM2_LIB }}
SIGNING_SERVER_BIN: ${{ github.workspace }}/signing-server
HSM_PUBLIC_KEY: ${{ github.workspace }}/public_key.pem
run: |
go test -v ./...