diff options
author | cajun-rat <p@beta16.co.uk> | 2017-09-13 13:50:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-13 13:50:44 +0200 |
commit | c32010321f84b500dab86d3c935138306244c539 (patch) | |
tree | c47ad5da85ff6931e32d5d5594345812248612e7 /recipes-support/softhsm-testtoken/files/createtoken.sh | |
parent | 364f2359cc61537f8e8dfa422eca0577bd1f35ec (diff) | |
parent | 4a7366c4f161a98611a292394a9662a0c507f904 (diff) | |
download | meta-updater-c32010321f84b500dab86d3c935138306244c539.tar.gz |
Merge pull request #136 from advancedtelematic/feat/PRO-3805/p11test
Add recipes to test pkcs11 functionality in Aktualizr
Diffstat (limited to 'recipes-support/softhsm-testtoken/files/createtoken.sh')
-rw-r--r-- | recipes-support/softhsm-testtoken/files/createtoken.sh | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/recipes-support/softhsm-testtoken/files/createtoken.sh b/recipes-support/softhsm-testtoken/files/createtoken.sh new file mode 100644 index 0000000..a72ec34 --- /dev/null +++ b/recipes-support/softhsm-testtoken/files/createtoken.sh | |||
@@ -0,0 +1,21 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | if pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so -O; then | ||
4 | # The token has already been initialized, exit | ||
5 | exit 0 | ||
6 | fi | ||
7 | |||
8 | if ! ls /var/sota/token/pkey.pem /var/sota/token/client.pem; then | ||
9 | # Key/certificate pair is not present, repeat | ||
10 | mkdir -p /var/sota/token | ||
11 | exit 1 | ||
12 | fi | ||
13 | |||
14 | mkdir -p /var/lib/softhsm/tokens | ||
15 | softhsm2-util --init-token --slot 0 --label "Virtual token" --pin 1234 --so-pin 1234 | ||
16 | |||
17 | pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so --label 'Virtual token' --write-object /var/sota/token/pkey.pem --type privkey --login --pin 1234 | ||
18 | openssl x509 -outform der -in /var/sota/token/client.pem -out /var/sota/token/client.der | ||
19 | pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so --label 'Virtual token' --write-object /var/sota/token/client.der --type cert --login --pin 1234 | ||
20 | |||
21 | exit 0 | ||