Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] Use multiple CAs instead of a single self-signed root CA #327

Open
wants to merge 3 commits into
base: humble
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions sros2/sros2/keystore/_keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
_DEFAULT_COMMON_NAME = 'sros2CA'


def create_keystore(keystore_path: pathlib.Path) -> None:
def create_keystore(keystore_path: pathlib.Path, split_CA=False) -> None:
if is_valid_keystore(keystore_path):
raise sros2.errors.KeystoreExistsError(keystore_path)

Expand Down Expand Up @@ -65,11 +65,19 @@ def create_keystore(keystore_path: pathlib.Path) -> None:
if not all(x.is_file() for x in required_files):
_create_ca_key_cert(keystore_ca_key_path, keystore_ca_cert_path)

for path in (keystore_permissions_ca_cert_path, keystore_identity_ca_cert_path):
_utilities.create_symlink(src=pathlib.Path('ca.cert.pem'), dst=path)

for path in (keystore_permissions_ca_key_path, keystore_identity_ca_key_path):
_utilities.create_symlink(src=pathlib.Path('ca.key.pem'), dst=path)
if split_CA:
# Create independent Permissions and Identity CA
_create_ca_key_cert(keystore_permissions_ca_key_path,
keystore_permissions_ca_cert_path)
_create_ca_key_cert(keystore_identity_ca_key_path,
keystore_identity_ca_cert_path)
else:
# Use the root CA as Permissions and Identity CA
for path in (keystore_permissions_ca_cert_path, keystore_identity_ca_cert_path):
_utilities.create_symlink(src=pathlib.Path('ca.cert.pem'), dst=path)

for path in (keystore_permissions_ca_key_path, keystore_identity_ca_key_path):
_utilities.create_symlink(src=pathlib.Path('ca.key.pem'), dst=path)

# Create governance file if it doesn't already exist
gov_path = keystore_path.joinpath(_KS_ENCLAVES, 'governance.xml')
Expand Down
5 changes: 4 additions & 1 deletion sros2/sros2/verb/create_keystore.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,14 @@ class CreateKeystoreVerb(VerbExtension):

def add_arguments(self, parser, cli_name) -> None:
arg = parser.add_argument('ROOT', type=pathlib.Path, help='root path of keystore')
arg = parser.add_argument('--split-CA', action='store_true', default=False,
help='splits the Certificate Authority structure to \
use multiple CAs instead of a single self-signed root CA')
arg.completer = DirectoriesCompleter()

def main(self, *, args) -> int:
try:
sros2.keystore.create_keystore(args.ROOT)
sros2.keystore.create_keystore(args.ROOT, args.split_CA)
except sros2.errors.SROS2Error as e:
print(f'Unable to create keystore: {str(e)}', file=sys.stderr)
return 1
Expand Down