11#! /bin/bash
22set -e
33
4- # Get the directory where this script is located to find permissions.xml
54SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
65
76# This script generates the ROS 2 security keystore and keys for all nodes
4342
4443echo " Empty keystore volume detected. Generating fresh security artifacts..."
4544
46- # WORKAROUND: `create_keystore` requires the target directory to not exist,
47- # but we can't remove the volume mount point. So, we create it in a temporary
48- # location and then move the contents into the empty volume.
4945TMP_KEYSTORE_DIR=$( mktemp -d)
5046ros2 security create_keystore " $TMP_KEYSTORE_DIR "
5147
@@ -55,22 +51,12 @@ rm -rf "$TMP_KEYSTORE_DIR"
5551
5652ENCLAVE_NAME=" /dicom_to_ros"
5753
58- # The `create_enclave` command in Jazzy is designed to create the enclave
59- # and all node keys defined in the policy file in a single step.
60- # In ROS 2 Jazzy, the `create_enclave` command is intended to generate all
61- # keys and permissions from a policy file in a single step.
6254echo " Creating enclave and generating keys for all nodes from policy file..."
6355
64- # The 'create_enclave' command and its arguments have changed in recent ROS 2 versions.
65- # The modern approach is to create keys for each node individually and then
66- # create the signed permissions file for the enclave.
67- echo " Creating enclave and generating keys for all nodes from policy file..."
68- # The modern `create_enclave` command handles generating all necessary keys and certificates.
6956ros2 security create_enclave " $KEYSTORE_DIR " " $ENCLAVE_NAME "
7057
71- # The `create_permission` command then signs the policy file using the generated enclave certificate.
7258echo " Creating signed permissions for enclave: $ENCLAVE_NAME "
7359ros2 security create_permission " $KEYSTORE_DIR " " $ENCLAVE_NAME " " $SCRIPT_DIR /permissions.xml"
7460
7561# Store a checksum of the policy file to detect future changes.
76- md5sum " $POLICY_FILE " > " $CHECKSUM_FILE "
62+ md5sum " $POLICY_FILE " > " $CHECKSUM_FILE "
0 commit comments