Skip to content
Merged
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
18 changes: 5 additions & 13 deletions .github/workflows/keyfactor-starter-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,9 @@ on:

jobs:
call-starter-workflow:
uses: keyfactor/actions/.github/workflows/starter.yml@v4
with:
command_token_url: ${{ vars.COMMAND_TOKEN_URL }} # Only required for doctool generated screenshots
command_hostname: ${{ vars.COMMAND_HOSTNAME }} # Only required for doctool generated screenshots
command_base_api_path: ${{ vars.COMMAND_API_PATH }} # Only required for doctool generated screenshots
uses: keyfactor/actions/.github/workflows/starter.yml@v5
secrets:
token: ${{ secrets.V2BUILDTOKEN}} # REQUIRED
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }} # Only required for golang builds
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }} # Only required for golang builds
scan_token: ${{ secrets.SAST_TOKEN }} # REQUIRED
entra_username: ${{ secrets.DOCTOOL_ENTRA_USERNAME }} # Only required for doctool generated screenshots
entra_password: ${{ secrets.DOCTOOL_ENTRA_PASSWD }} # Only required for doctool generated screenshots
command_client_id: ${{ secrets.COMMAND_CLIENT_ID }} # Only required for doctool generated screenshots
command_client_secret: ${{ secrets.COMMAND_CLIENT_SECRET }} # Only required for doctool generated screenshots
token: ${{ secrets.V2BUILDTOKEN }}
gpg_key: ${{ secrets.KF_GPG_PRIVATE_KEY }}
gpg_pass: ${{ secrets.KF_GPG_PASSPHRASE }}
scan_token: ${{ secrets.SAST_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
Expand All @@ -10,6 +10,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Microsoft.Graph" Version="5.54.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
<PackageReference Include="xunit" Version="2.4.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
public string Resolve(string instanceInfo)
{
// For testing, if we have a predefined secret, return it
if (_secrets.ContainsKey(instanceInfo))
if (instanceInfo != null && _secrets.ContainsKey(instanceInfo))
{
return _secrets[instanceInfo];
}

// Otherwise, just return the input (simulating no PAM resolution needed)
return instanceInfo;

Check warning on line 33 in AzureEnterpriseApplicationOrchestrator.Tests/MockPAMSecretResolver.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

Possible null reference return.
}

public void AddSecret(string key, string value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<TargetFrameworks>net6.0;net8.0;net10.0</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<ImplicitUsings>disable</ImplicitUsings>
<NoWarn>$(NoWarn);SYSLIB0057</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand All @@ -16,13 +17,13 @@
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Keyfactor.Logging" Version="1.1.0" Condition="'$(TargetFramework)' == 'net6.0'"/>
<PackageReference Include="Keyfactor.Logging" Version="1.3.0" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageReference Include="Keyfactor.Logging" Version="1.3.0" Condition="'$(TargetFramework)' == 'net10.0'"/>
<PackageReference Include="Keyfactor.Logging" Version="1.3.0" Condition="'$(TargetFramework)' == 'net8.0'"/>
<PackageReference Include="Keyfactor.Logging" Version="1.3.0" Condition="'$(TargetFramework)' == 'net10.0'"/>
<PackageReference Include="Keyfactor.Orchestrators.Common" Version="3.4.0" />
<PackageReference Include="Keyfactor.Orchestrators.IOrchestratorJobExtensions" Version="1.0.0" />
<PackageReference Include="Microsoft.Graph" Version="5.54.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.4" />
<PackageReference Include="System.Drawing.Common" Version="6.0.0" />
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 8 additions & 8 deletions AzureEnterpriseApplicationOrchestrator/Client/GraphClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2024 Keyfactor
// Copyright 2026 Keyfactor
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -122,7 +122,7 @@
_azureCloudEndpoint = AzureAuthorityHosts.AzureChina;
break;
case "germany":
_azureCloudEndpoint = AzureAuthorityHosts.AzureGermany;

Check warning on line 125 in AzureEnterpriseApplicationOrchestrator/Client/GraphClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

'AzureAuthorityHosts.AzureGermany' is obsolete: 'Microsoft Cloud Germany was closed on October 29th, 2021.'

Check warning on line 125 in AzureEnterpriseApplicationOrchestrator/Client/GraphClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

'AzureAuthorityHosts.AzureGermany' is obsolete: 'Microsoft Cloud Germany was closed on October 29th, 2021.'

Check warning on line 125 in AzureEnterpriseApplicationOrchestrator/Client/GraphClient.cs

View workflow job for this annotation

GitHub Actions / call-starter-workflow / call-dotnet-build-and-release-workflow / dotnet-build-and-release

'AzureAuthorityHosts.AzureGermany' is obsolete: 'Microsoft Cloud Germany was closed on October 29th, 2021.'
break;
case "government":
_azureCloudEndpoint = AzureAuthorityHosts.AzureGovernment;
Expand Down Expand Up @@ -242,15 +242,13 @@
throw new Exception("Could not calculate thumbprint for certificate");

// Calculate the SHA256 hash of the certificate's thumbprint
byte[] customKeyId = Encoding.UTF8.GetBytes(certificate.Thumbprint)[..32];
byte[] customKeyId = certificate.GetCertHash();

_logger.LogDebug($"Adding certificate called \"{certificateName}\" to Object ID \"{_targetObjectId}\" (custom key ID {Encoding.UTF8.GetString(customKeyId)})");
_logger.LogDebug($"Adding certificate called \"{certificateName}\" to Object ID \"{_targetObjectId}\" (custom key ID {Convert.ToHexString(customKeyId)})");

// Get the application object
Application application = GetApplication();

char[] certPem = PemEncoding.Write("CERTIFICATE", certificate.RawData);

// Update the application object
_logger.LogDebug($"Updating application object for Object ID \"{_targetObjectId}\"");
try
Expand All @@ -267,7 +265,7 @@
StartDateTime = DateTimeOffset.Parse(certificate.GetEffectiveDateString()),
EndDateTime = DateTimeOffset.Parse(certificate.GetExpirationDateString()),
KeyId = Guid.NewGuid(),
Key = System.Text.Encoding.UTF8.GetBytes(certPem)
Key = certificate.Export(X509ContentType.Cert),
}
}
}).Wait();
Expand Down Expand Up @@ -332,6 +330,7 @@

public void AddServicePrincipalCertificate(string certificateName, string certificateData, string certificatePassword)
{

// certificateData is a base64 encoded PFX certificate
X509Certificate2 certificate = SerializeCertificate(certificateData, certificatePassword);
if (certificate.Thumbprint == null)
Expand Down Expand Up @@ -801,7 +800,7 @@

foreach (KeyCredential keyCredential in keyCredentials)
{
string customKeyIdentifier = Encoding.UTF8.GetString(keyCredential.CustomKeyIdentifier);
string customKeyIdentifier = Convert.ToHexString(keyCredential.CustomKeyIdentifier);

if (!string.IsNullOrWhiteSpace(keyCredential.Usage) && keyCredential.Usage.Equals("Sign", StringComparison.OrdinalIgnoreCase))
{
Expand Down Expand Up @@ -989,8 +988,9 @@
return certificate;
}

protected static X509Certificate2 SerializeCertificate(string certificateData, string password)
private X509Certificate2 SerializeCertificate(string certificateData, string password)
{
_logger.LogDebug($"Certificate Base64: {certificateData}");
byte[] rawData = Convert.FromBase64String(certificateData);
return new X509Certificate2(rawData, password, X509KeyStorageFlags.Exportable);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public GraphJobClientBuilder<TBuilder> WithV2CertificateStoreDetails(Certificate
if (!string.IsNullOrEmpty(serverPassword))
{
_logger.LogDebug("Client certificate not present - Using Client Secret authentication");
_logger.LogTrace($"Builder - ServerPassword => ClientSecret: {properties.ServerPassword}");
_logger.LogTrace($"Builder - ServerPassword => ClientSecret: ******");
_builder.WithClientSecret(serverPassword);
}
else if (!string.IsNullOrEmpty(properties.ClientCertificate))
Expand Down
Loading
Loading