diff options
author | Anton Gerasimov <anton@advancedtelematic.com> | 2017-09-27 10:14:32 +0200 |
---|---|---|
committer | Anton Gerasimov <anton@advancedtelematic.com> | 2017-10-16 12:42:37 +0200 |
commit | 9d9b6a8eb297e7e90a680730bfc5068deb19a138 (patch) | |
tree | 3735d77f600ff18d1219ad3f8ecc346188eadae7 /recipes-support | |
parent | 36f1d8668a0ccdfe7f71f886a6829fb33be7cb48 (diff) | |
download | meta-updater-9d9b6a8eb297e7e90a680730bfc5068deb19a138.tar.gz |
Support pkcs#11 in aktualizr and add softhsm token for testing
Diffstat (limited to 'recipes-support')
-rw-r--r-- | recipes-support/softhsm-testtoken/files/createtoken.sh | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/recipes-support/softhsm-testtoken/files/createtoken.sh b/recipes-support/softhsm-testtoken/files/createtoken.sh index a72ec34..b01db47 100644 --- a/recipes-support/softhsm-testtoken/files/createtoken.sh +++ b/recipes-support/softhsm-testtoken/files/createtoken.sh | |||
@@ -5,17 +5,22 @@ if pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so -O; then | |||
5 | exit 0 | 5 | exit 0 |
6 | fi | 6 | fi |
7 | 7 | ||
8 | if ! ls /var/sota/token/pkey.pem /var/sota/token/client.pem; then | 8 | if ! ls /var/sota/token/pkey.pem /var/sota/token/client.pem /var/sota/token/pkey.pem; then |
9 | # Key/certificate pair is not present, repeat | 9 | # Key/certificate pair is not present, repeat |
10 | mkdir -p /var/sota/token | ||
11 | exit 1 | 10 | exit 1 |
12 | fi | 11 | fi |
13 | 12 | ||
14 | mkdir -p /var/lib/softhsm/tokens | 13 | mkdir -p /var/lib/softhsm/tokens |
15 | softhsm2-util --init-token --slot 0 --label "Virtual token" --pin 1234 --so-pin 1234 | 14 | softhsm2-util --init-token --slot 0 --label "Virtual token" --pin 1234 --so-pin 1234 |
16 | 15 | ||
17 | pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so --label 'Virtual token' --write-object /var/sota/token/pkey.pem --type privkey --login --pin 1234 | 16 | softhsm2-util --import /var/sota/token/pkey.pem --label "pkey" --id 02 --token 'Virtual token' --pin 1234 |
18 | openssl x509 -outform der -in /var/sota/token/client.pem -out /var/sota/token/client.der | 17 | 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 | 18 | pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so --id 1 --write-object /var/sota/token/client.der --type cert --login --pin 1234 |
19 | |||
20 | # Import UPTANE keypair if it exists | ||
21 | if [ -f /var/sota/token/ecukey.pem ]; then | ||
22 | openssl pkcs8 -topk8 -inform PEM -outform PEM -nocrypt -in /var/sota/token/ecukey.pem -out /var/sota/token/ecukey.p8 | ||
23 | softhsm2-util --import /var/sota/token/ecukey.p8 --label "uptanekey" --id 03 --token 'Virtual token' --pin 1234 | ||
24 | fi | ||
20 | 25 | ||
21 | exit 0 | 26 | exit 0 |