From 40a6fe9e0da31631f86fffd133af628b601c76bc Mon Sep 17 00:00:00 2001 From: Koen Van Looveren Date: Tue, 12 Dec 2023 20:28:37 +0100 Subject: [PATCH] fix: check if keychain already exists --- CHANGELOG.md | 5 +++++ .../apple_certificate/plugin/mac_os_keychain_plugin.dart | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b44b7f..52a9e73 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 0.10.5 + +# Fix: +- First check if new keychain already exists before creating a new one + # 0.10.4 # Fix: diff --git a/lib/src/integrations/apple_certificate/plugin/mac_os_keychain_plugin.dart b/lib/src/integrations/apple_certificate/plugin/mac_os_keychain_plugin.dart index fcd8054..8bffde1 100644 --- a/lib/src/integrations/apple_certificate/plugin/mac_os_keychain_plugin.dart +++ b/lib/src/integrations/apple_certificate/plugin/mac_os_keychain_plugin.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'package:impaktfull_cli/src/core/model/data/secret.dart'; +import 'package:impaktfull_cli/src/core/model/error/impaktfull_cli_error.dart'; import 'package:impaktfull_cli/src/core/plugin/impaktfull_cli_plugin.dart'; import 'package:impaktfull_cli/src/core/util/logger/logger.dart'; import 'package:impaktfull_cli/src/core/util/process/process_runner.dart'; @@ -17,6 +18,12 @@ class MacOsKeyChainPlugin extends ImpaktfullCliPlugin { Secret globalKeyChainPassword, ) async { final fullKeyChainName = _fullKeyChainName(keyChainName); + final originalKeyChains = await _getUserKeyChains(); + if (originalKeyChains.contains(fullKeyChainName)) { + throw ImpaktfullCliError( + '$fullKeyChainName already exists, make sure to remove it first.'); + } + ImpaktfullCliLogger.debug('Create Apple KeyChain ($fullKeyChainName)'); await processRunner.runProcess([ 'security',