|
2 | 2 |
|
3 | 3 | Can be used to make a bridge with PKCS#11 windows-only module to use it on linux. |
4 | 4 |
|
| 5 | +(Info) You can get small binaries compressed with UPX (prefixed by 's' in releases). |
| 6 | + |
5 | 7 | ## Usage |
6 | 8 | ### Generate certs |
7 | 9 | ```bash |
@@ -38,6 +40,62 @@ p11tool --provider=$(pwd)/pkcs11-proxy-module.so --generate-random=256 |
38 | 40 | p11tool --provider=$(pwd)/pkcs11-proxy-module.so --list-mechanisms |
39 | 41 | ``` |
40 | 42 |
|
| 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 | + |
41 | 99 | ## Build |
42 | 100 | ```bash |
43 | 101 | sudo apt-get update && sudo apt-get install gcc-multilib curl unzip gcc gcc-mingw-w64 -y |
|
0 commit comments