Skip to content

Commit 9310b44

Browse files
authored
Merge pull request #2 from Keyfactor/ab#17762
Ab#17762
2 parents af385fa + 78e9050 commit 9310b44

13 files changed

+437
-188
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Keyfactor Merge Cert Store Types
2+
on: [workflow_dispatch]
3+
4+
jobs:
5+
get-manifest-properties:
6+
runs-on: windows-latest
7+
outputs:
8+
update_catalog: ${{ steps.read-json.outputs.update_catalog }}
9+
integration_type: ${{ steps.read-json.outputs.integration_type }}
10+
steps:
11+
- uses: actions/checkout@v3
12+
- name: Store json
13+
id: read-json
14+
shell: pwsh
15+
run: |
16+
$json = Get-Content integration-manifest.json | ConvertFrom-Json
17+
$myvar = $json.update_catalog
18+
echo "update_catalog=$myvar" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
19+
$myvar = $json.integration_type
20+
echo "integration_type=$myvar" | Out-File -FilePath $Env:GITHUB_OUTPUT -Encoding utf8 -Append
21+
22+
call-update-store-types-workflow:
23+
needs: get-manifest-properties
24+
if: needs.get-manifest-properties.outputs.integration_type == 'orchestrator' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
25+
uses: Keyfactor/actions/.github/workflows/update-store-types.yml@main
26+
secrets:
27+
token: ${{ secrets.UPDATE_STORE_TYPES }}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Keyfactor Bootstrap Workflow
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
types: [opened, closed, synchronize, edited, reopened]
7+
push:
8+
create:
9+
branches:
10+
- 'release-*.*'
11+
12+
jobs:
13+
call-starter-workflow:
14+
uses: keyfactor/actions/.github/workflows/[email protected]
15+
secrets:
16+
token: ${{ secrets.V2BUILDTOKEN}}
17+
APPROVE_README_PUSH: ${{ secrets.APPROVE_README_PUSH}}
18+
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
19+
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
20+
scan_token: ${{ secrets.SAST_TOKEN }}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
v1.0.0
2+
- Initial Version

GCPSecretManager/GCPClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public void AddSecret(string alias, string secretContent, bool entryExists)
121121
}
122122
catch (Exception ex)
123123
{
124-
_logger.LogError(GCPException.FlattenExceptionMessages(ex, "Error adding/replacing certificate"));
124+
_logger.LogError(GCPException.FlattenExceptionMessages(ex, "Error adding/replacing certificate. "));
125125
throw;
126126
}
127127
finally

GCPSecretManager/Inventory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public JobResult ProcessJob(InventoryJobConfiguration config, SubmitInventoryUpd
8585
}
8686
catch (Exception ex)
8787
{
88-
return new JobResult() { Result = Keyfactor.Orchestrators.Common.Enums.OrchestratorJobStatusJobResult.Failure, JobHistoryId = config.JobHistoryId, FailureMessage = GCPException.FlattenExceptionMessages(ex, $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: Error performing Inventory.") };
88+
return new JobResult() { Result = Keyfactor.Orchestrators.Common.Enums.OrchestratorJobStatusJobResult.Failure, JobHistoryId = config.JobHistoryId, FailureMessage = GCPException.FlattenExceptionMessages(ex, $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: Error performing Inventory. ") };
8989
}
9090
}
9191
}

GCPSecretManager/Management.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public JobResult ProcessJob(ManagementJobConfiguration config)
5252
}
5353
catch (Exception ex)
5454
{
55-
return new JobResult() { Result = Keyfactor.Orchestrators.Common.Enums.OrchestratorJobStatusJobResult.Failure, JobHistoryId = config.JobHistoryId, FailureMessage = GCPException.FlattenExceptionMessages(ex, $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: Error adding certificate for {config.JobCertificate.Alias}") };
55+
return new JobResult() { Result = Keyfactor.Orchestrators.Common.Enums.OrchestratorJobStatusJobResult.Failure, JobHistoryId = config.JobHistoryId, FailureMessage = GCPException.FlattenExceptionMessages(ex, $"Site {config.CertificateStoreDetails.StorePath} on server {config.CertificateStoreDetails.ClientMachine}: Error adding certificate for {config.JobCertificate.Alias}. ") };
5656
}
5757

5858
return new JobResult() { Result = Keyfactor.Orchestrators.Common.Enums.OrchestratorJobStatusJobResult.Success, JobHistoryId = config.JobHistoryId };
@@ -68,8 +68,10 @@ private void PerformAdd(ManagementJobConfiguration config, GCPClient client)
6868

6969
if (!config.Overwrite && entryExists)
7070
{
71+
string errMsg = $"Secret {alias} already exists but Overwrite set to False. Set Overwrite to True to replace the certificate.";
72+
Logger.LogError(errMsg);
7173
Logger.MethodExit(LogLevel.Debug);
72-
throw new GCPException($"Secret {alias} already exists but Overwrite set to False. Set Overwrite to True to replace the certificate.");
74+
throw new GCPException(errMsg);
7375
}
7476

7577
if (string.IsNullOrEmpty(StorePassword))
@@ -85,7 +87,10 @@ private void PerformAdd(ManagementJobConfiguration config, GCPClient client)
8587
string secret = CertificateFormatter.ConvertCertificateEntryToSecret(config.JobCertificate.Contents, config.JobCertificate.PrivateKeyPassword, IncludeChain, newPassword);
8688
client.AddSecret(alias, secret, entryExists);
8789
if (!string.IsNullOrEmpty(newPassword) && string.IsNullOrEmpty(StorePassword))
88-
client.AddSecret(alias + PasswordSecretSuffix, newPassword, entryExists);
90+
{
91+
bool passwordEntryExists = client.Exists(alias + PasswordSecretSuffix);
92+
client.AddSecret(alias + PasswordSecretSuffix, newPassword, passwordEntryExists);
93+
}
8994
}
9095
catch { throw; }
9196
finally

0 commit comments

Comments
 (0)