summaryrefslogtreecommitdiffstats
path: root/recipes-support/softhsm-testtoken/files/createtoken.sh
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-support/softhsm-testtoken/files/createtoken.sh')
-rw-r--r--recipes-support/softhsm-testtoken/files/createtoken.sh13
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
6fi 6fi
7 7
8if ! ls /var/sota/token/pkey.pem /var/sota/token/client.pem; then 8if ! 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
12fi 11fi
13 12
14mkdir -p /var/lib/softhsm/tokens 13mkdir -p /var/lib/softhsm/tokens
15softhsm2-util --init-token --slot 0 --label "Virtual token" --pin 1234 --so-pin 1234 14softhsm2-util --init-token --slot 0 --label "Virtual token" --pin 1234 --so-pin 1234
16 15
17pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so --label 'Virtual token' --write-object /var/sota/token/pkey.pem --type privkey --login --pin 1234 16softhsm2-util --import /var/sota/token/pkey.pem --label "pkey" --id 02 --token 'Virtual token' --pin 1234
18openssl x509 -outform der -in /var/sota/token/client.pem -out /var/sota/token/client.der 17openssl x509 -outform der -in /var/sota/token/client.pem -out /var/sota/token/client.der
19pkcs11-tool --module=/usr/lib/softhsm/libsofthsm2.so --label 'Virtual token' --write-object /var/sota/token/client.der --type cert --login --pin 1234 18pkcs11-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
21if [ -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
24fi
20 25
21exit 0 26exit 0