Skip to content

Commit 9192851

Browse files
committed
Add upx for all binaries
1 parent c982020 commit 9192851

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

.github/workflows/go-release.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@ jobs:
2424
curl -o protoc.zip -L 'https://github.com/protocolbuffers/protobuf/releases/download/v27.0/protoc-27.0-linux-x86_64.zip'
2525
unzip protoc.zip
2626
popd
27+
mkdir -p $HOME/upx && pushd $HOME/upx
28+
curl -o upx.tar.xz -L 'https://github.com/upx/upx/releases/download/v4.2.4/upx-4.2.4-amd64_linux.tar.xz'
29+
tar xJf upx.tar.xz
30+
cp upx-*/upx .
31+
popd
2732
- name: Build
2833
run: |
29-
export PATH=$HOME/.local/bin:$HOME/protobuf/bin:$PATH
34+
export PATH=$HOME/.local/bin:$HOME/protobuf/bin:$HOME/upx:$PATH
3035
make dev-dependencies
3136
make
37+
chmod +x pkcs11-proxy* && find . -maxdepth 1 -type f -name "pkcs11-proxy-*" -exec sh -c 'upx --best -o s$(basename {}) {}' \;
3238
- uses: softprops/action-gh-release@v2
3339
with:
34-
files: "pkcs11-proxy-*"
40+
files: "*pkcs11-proxy-*"
3541
env:
3642
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ pkcs11-proxy-module.dll
33
pkcs11-proxy-module.h
44
pkcs11-proxy-server
55
pkcs11-proxy-server.exe
6+
spkcs11-proxy*
67
*.crt
78
*.key
89
*.csr

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
all: pkcs11-proxy-module.so pkcs11-proxy-module.dll pkcs11-proxy-server pkcs11-proxy-server.exe
33

44
clean:
5-
rm -f *.so *.dll pkcs11-proxy-module.*
5+
rm -f *.so *.dll pkcs11-proxy-server* spkcs11-proxy-server*
66

77
.PHONY: pkcs11-proxy-server
88
pkcs11-proxy-server: protoc

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Can be used to make a bridge with PKCS#11 windows-only module to use it on linux.
44

5+
(Info) You can get small binaries compressed with UPX (prefixed by 's' in releases).
6+
57
## Usage
68
### Generate certs
79
```bash
@@ -38,6 +40,62 @@ p11tool --provider=$(pwd)/pkcs11-proxy-module.so --generate-random=256
3840
p11tool --provider=$(pwd)/pkcs11-proxy-module.so --list-mechanisms
3941
```
4042

43+
### Example usage
44+
```bash
45+
# Install softhsm2
46+
sudo apt-get update
47+
sudo apt-get install -y softhsm2 gnutls-bin curl
48+
# Initialize softhsm2 token
49+
mkdir -p $HOME/.local/softhsm2/tokens
50+
cat > $HOME/.softhsm2.conf <<EOF
51+
# SoftHSM v2 configuration file
52+
53+
directories.tokendir = $HOME/.local/softhsm2/tokens/
54+
objectstore.backend = file
55+
56+
# ERROR, WARNING, INFO, DEBUG
57+
log.level = ERROR
58+
59+
# If CKF_REMOVABLE_DEVICE flag should be set
60+
slots.removable = false
61+
62+
# Enable and disable PKCS#11 mechanisms using slots.mechanisms.
63+
slots.mechanisms = ALL
64+
65+
# If the library should reset the state on fork
66+
library.reset_on_fork = false
67+
EOF
68+
softhsm2-util --init-token --slot 0 --label "My token 1" --pin 1234 --so-pin 1234
69+
export SOFTHSM2_CONF=$HOME/.softhsm2.conf
70+
# Install server
71+
curl -LO https://github.com/ryarnyah/pkcs11-go-proxy/releases/latest/download/spkcs11-proxy-server
72+
chmod +x pkcs11-proxy-server
73+
74+
# Install client
75+
curl -LO https://github.com/ryarnyah/pkcs11-go-proxy/releases/latest/download/spkcs11-proxy-module.so
76+
77+
# Generate tls keys
78+
curl -LO https://github.com/ryarnyah/pkcs11-go-proxy/raw/main/generate-keys.sh
79+
chmod +x generate-keys.sh
80+
./generate-keys.sh
81+
82+
# Launch server
83+
export PKCS11_PROXY_ALLOWED_MODULES="/usr/lib/softhsm/libsofthsm2.so"
84+
export PKCS11_PROXY_URI="localhost:8080"
85+
export PKCS11_PROXY_CACERT=$(pwd)/ca.crt
86+
export PKCS11_PROXY_KEY=$(pwd)/server.key
87+
export PKCS11_PROXY_CERT=$(pwd)/server.crt
88+
./pkcs11-proxy-server &
89+
90+
# Test client
91+
export PKCS11_PROXY_URI="localhost:8080"
92+
export PKCS11_PROXY_CACERT=$(pwd)/ca.crt
93+
export PKCS11_PROXY_KEY=$(pwd)/client.key
94+
export PKCS11_PROXY_CERT=$(pwd)/client.crt
95+
export PKCS11_MODULE="/usr/lib/softhsm/libsofthsm2.so"
96+
p11tool --provider=$(pwd)/spkcs11-proxy-module.so --list-mechanisms
97+
```
98+
4199
## Build
42100
```bash
43101
sudo apt-get update && sudo apt-get install gcc-multilib curl unzip gcc gcc-mingw-w64 -y

0 commit comments

Comments
 (0)