samples: Enable swtpm-localca to sign with a pkcs11 URI

Allow the user to specify a pkcs11 URI in the signingkey field
in swtpm-localca.conf.

Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Stefan Berger 2019-01-22 16:02:13 -05:00 committed by Stefan Berger
parent 2b0f421224
commit 7a3d1cde46

View File

@ -559,7 +559,18 @@ main() {
esac
# TPM keys are GNUTLS URLs...
if ! [[ "$SIGNKEY" =~ ^tpmkey:(uuid|file)= ]]; then
if [[ "$SIGNKEY" =~ ^tpmkey:(uuid|file)= ]]; then
export TSS_TCSD_HOSTNAME=$(get_config_value "$LOCALCA_CONFIG" \
"TSS_TCSD_HOSTNAME" "localhost")
export TSS_TCSD_PORT=$(get_config_value "$LOCALCA_CONFIG" \
"TSS_TCSD_PORT" "30003")
logit "CA uses a GnuTLS TPM key; using TSS_TCSD_HOSTNAME=${TSS_TCSD_HOSTNAME}" \
"TSS_TCSD_PORT=${TSS_TCSD_PORT}"
elif [[ "$SIGNKEY" =~ ^pkcs11: ]]; then
export SWTPM_PKCS11_PIN=$(get_config_value "$LOCALCA_CONFIG" \
"SWTPM_PKCS11_PIN" "swtpm-tpmca")
logit "CA uses a PKCS#11 key; using SWTPM_PKCS11_PIN"
else
if [ ! -r "$SIGNKEY" ]; then
if [ -f "$SIGNKEY" ]; then
logerr "Signing key $SIGNKEY exists but cannot access" \
@ -579,13 +590,6 @@ main() {
logerr "Cannot access signing key ${SIGNKEY}."
exit 1
fi
else
export TSS_TCSD_HOSTNAME=$(get_config_value "$LOCALCA_CONFIG" \
"TSS_TCSD_HOSTNAME" "localhost")
export TSS_TCSD_PORT=$(get_config_value "$LOCALCA_CONFIG" \
"TSS_TCSD_PORT" "30003")
logit "CA uses a GnuTLS TPM key; using TSS_TCSD_HOSTNAME=${TSS_TCSD_HOSTNAME}" \
"TSS_TCSD_PORT=${TSS_TCSD_PORT}"
fi
if [ ! -r "$ISSUERCERT" ]; then