Skip to content

Commit

Permalink
update store
Browse files Browse the repository at this point in the history
  • Loading branch information
afifi-ins committed Jul 23, 2024
1 parent 8dd470c commit 5787e3c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
14 changes: 5 additions & 9 deletions eng/SendToHelix.proj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
<TestRunNamePrefix>$(AGENT_JOBNAME)</TestRunNamePrefix>
<EnableXUnitReporter>true</EnableXUnitReporter>
</PropertyGroup>

<!--<PropertyGroup>
<RunWithCoreWCFService Condition="'$(RunWithCoreWCFService)' == ''">false</RunWithCoreWCFService>
</PropertyGroup>-->

<Target Name="InstallDotNet">
<ItemGroup>
Expand Down Expand Up @@ -75,15 +71,15 @@
</PropertyGroup>

<PropertyGroup>
<RunWithCoreWcfService>true</RunWithCoreWcfService>
<RunWithCoreWCFService Condition="'$(RunWithCoreWCFService)' == ''">false</RunWithCoreWCFService>
</PropertyGroup>

<PropertyGroup Condition="'$(RunWithCoreWcfService)' == 'false' And '$(TestJob)' != 'Windows'" >
<PropertyGroup Condition="'$(RunWithCoreWcfService)' == 'false' AND '$(TestJob)' != 'Windows'" >
<HelixPreCommands>$(HelixPreCommands);chmod a+x $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);sudo -E -n $HELIX_CORRELATION_PAYLOAD/InstallRootCertificate.sh --service-host $(ServiceHost) --cert-file /tmp/wcfrootca.crt</HelixPreCommands>
</PropertyGroup>

<PropertyGroup Condition="'$(TestJob)' == 'Windows'">
<PropertyGroup Condition="'$(RunWithCoreWcfService)' == 'true' AND '$(TestJob)' == 'Windows'">
<HelixPreCommands>$(HelixPreCommands);set PATH=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli%3B%PATH%</HelixPreCommands>
<!-- %3B is an escaped ; -->
<HelixPreCommands>$(HelixPreCommands);set DOTNET_ROOT=%HELIX_CORRELATION_PAYLOAD%\dotnet-cli;set DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
Expand All @@ -93,7 +89,7 @@
<HelixPreCommands>$(HelixPreCommands);%HELIX_CORRELATION_PAYLOAD%\SelfHostedCoreWCFService\$(Configuration)\net8.0\SelfHostedCoreWCFService bootstrap:true</HelixPreCommands>
</PropertyGroup>

<PropertyGroup Condition="'$(TestJob)' != 'Windows'">
<PropertyGroup Condition="'$(RunWithCoreWcfService)' == 'true' AND '$(TestJob)' != 'Windows'">
<HelixPreCommands>$(HelixPreCommands);export PATH=$HELIX_CORRELATION_PAYLOAD/dotnet-cli:$PATH</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export DOTNET_ROOT=$HELIX_CORRELATION_PAYLOAD/dotnet-cli;export DOTNET_CLI_TELEMETRY_OPTOUT=1</HelixPreCommands>
<HelixPreCommands>$(HelixPreCommands);export DOTNET_CLI_HOME=$HELIX_WORKITEM_ROOT/.dotnet</HelixPreCommands>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,12 @@ public static bool AddToStoreIfNeeded(StoreName storeName, StoreLocation storeLo
try
{
store = CertificateHelper.GetX509Store(storeName, storeLocation);

// We assume Bridge is running elevated
store.Open(OpenFlags.ReadWrite);
if (!CertificateHelper.CurrentOperatingSystem.IsMacOS())
{
store.Open(OpenFlags.ReadWrite);
}
existingCert = CertificateFromThumbprint(store, certificate.Thumbprint);
if (existingCert == null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,10 @@ public static X509Certificate2 CertificateFromSubject(StoreName name, StoreLocat
try
{
store = CertificateHelper.GetX509Store(name, location);
store.Open(OpenFlags.ReadOnly);
if (!store.IsOpen)
{
store.Open(OpenFlags.ReadOnly);
}
X509Certificate2Collection foundCertificates = store.Certificates.Find(X509FindType.FindBySubjectName, subjectName, validOnly: true);
return foundCertificates.Count == 0 ? null : foundCertificates[0];
}
Expand All @@ -234,7 +237,10 @@ public static X509Certificate2 CertificateFromFriendlyName(StoreName name, Store
try
{
store = CertificateHelper.GetX509Store(name, location);
store.Open(OpenFlags.ReadOnly);
if (!store.IsOpen)
{
store.Open(OpenFlags.ReadOnly);
}

X509Certificate2Collection foundCertificates = store.Certificates.Find(X509FindType.FindByIssuerName, "DO_NOT_TRUST_WcfBridgeRootCA", false);
string friendlyNameHash = CertificateGenerator.HashFriendlyNameToString(friendlyName);
Expand Down

0 comments on commit 5787e3c

Please sign in to comment.