Skip to content

Commit

Permalink
[wasm][xharness] install development SSL certificate on Helix agent b…
Browse files Browse the repository at this point in the history
…efore xharness run via SDK or powershell (#53280)

Co-authored-by: Ankit Jain <radical@gmail.com>

Caused by #53180, #53225

- The original approach to install certificates didn't work because we don't have dotnet SDK, just runtime on Helix agents.
- dotnet dev-certs https needs user interaction with a dialog. Instead, using powershelgl to install certs
- Wasm.Build.Tests are being disabled here because of #53405

Fixes #53207
  • Loading branch information
pavelsavara committed May 28, 2021
1 parent b759ac9 commit 72936ec
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 15 deletions.
2 changes: 1 addition & 1 deletion eng/pipelines/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ jobs:
creator: dotnet-bot
testRunNamePrefixSuffix: Mono_$(_BuildConfig)
scenarios:
- buildwasmapps
#- buildwasmapps - https://github.com/dotnet/runtime/issues/53405
- normal
- wasmtestonbrowser
condition: >-
Expand Down
43 changes: 29 additions & 14 deletions src/libraries/sendtohelixhelp.proj
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,10 @@

<PropertyGroup Condition="'$(TestPackages)' == 'true'">
<!-- Use Helix feature to include dotnet CLI for every workitem and add it to the path -->
<IncludeDotNetCli>true</IncludeDotNetCli>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
<NeedsDotNetSdk>true</NeedsDotNetSdk>
<UseDotNetCliVersionFromGlobalJson>true</UseDotNetCliVersionFromGlobalJson>

<TestRunNamePrefix>packaging-</TestRunNamePrefix>
<GlobalJsonContent>$([System.IO.File]::ReadAllText('$(RepoRoot)global.json'))</GlobalJsonContent>
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F&lt;="dotnet": ").*(%3F=")'))</DotNetCliVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(HelixType)' == ''">
Expand Down Expand Up @@ -105,27 +103,28 @@
<HelixPreCommand Include="set XHARNESS_DISABLE_COLORED_OUTPUT=true" />
<HelixPreCommand Include="set XHARNESS_LOG_WITH_TIMESTAMPS=true" />
</ItemGroup>
<ItemGroup Condition="'$(TargetOS)' == 'Browser'">

<PropertyGroup Condition="'$(TargetOS)' == 'Browser'">
<!--
We are hosting the payloads for the WASM/browser on kestrel in the xharness process.
We also run some network tests to this server and so, we are running it on both HTTP and HTTPS.
For the HTTPS endpoint we need development SSL certificate.
Below is alternative to `dotnet dev-certs https` but we don't have full SDK installed on helix, so the tool is not available.
-->
<HelixPreCommand Include="powershell -command &quot;New-SelfSignedCertificate -FriendlyName &#39;ASP.NET Core HTTPS development certificate&#39; -DnsName @(&#39;localhost&#39;) -Subject &#39;CN = localhost&#39; -KeyAlgorithm RSA -KeyLength 2048 -HashAlgorithm sha256 -CertStoreLocation &#39;Cert:\CurrentUser\My&#39; -TextExtension @(&#39;2.5.29.37={text}1.3.6.1.5.5.7.3.1&#39;,&#39;1.3.6.1.4.1.311.84.1.1={hex}02&#39;,&#39;2.5.29.19={text}&#39;) -KeyUsage DigitalSignature,KeyEncipherment&quot;" />
</ItemGroup>
<InstallDevCerts Condition="'$(Scenario)' != 'BuildWasmApps'">true</InstallDevCerts>

<!-- Install SDK so that, we could use `dotnet dev-certs https` -->
<NeedsDotNetSdk>true</NeedsDotNetSdk>
</PropertyGroup>

<ItemGroup Condition="'$(Scenario)' == 'WasmTestOnBrowser' or '$(Scenario)' == 'BuildWasmApps'">
<HelixPreCommand Include="export PATH=$HELIX_CORRELATION_PAYLOAD/chromedriver_linux64:$PATH" />
<HelixPreCommand Include="export PATH=$HELIX_CORRELATION_PAYLOAD/chrome-linux:$PATH" />
</ItemGroup>

<PropertyGroup Condition="'$(NeedsToBuildWasmAppsOnHelix)' == 'true'">
<NeedsDotNetSdk>true</NeedsDotNetSdk>
<UseDotNetCliVersionFromGlobalJson>true</UseDotNetCliVersionFromGlobalJson>
<IncludeXHarnessCli>true</IncludeXHarnessCli>
<IncludeDotNetCli>true</IncludeDotNetCli>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
<GlobalJsonContent>$([System.IO.File]::ReadAllText('$(RepoRoot)global.json'))</GlobalJsonContent>
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F&lt;="dotnet": ").*(%3F=")'))</DotNetCliVersion>
</PropertyGroup>

<!-- HelixPreCommands is a set of commands run before the work item command. We use it here to inject
Expand Down Expand Up @@ -162,15 +161,31 @@
<IncludeHelixCorrelationPayload Condition="'$(HelixCorrelationPayload)' != '' and '$(TargetOS)' != 'Browser'">true</IncludeHelixCorrelationPayload>
</PropertyGroup>

<PropertyGroup Condition="'$(NeedsDotNetSdk)' == 'true'">
<IncludeDotNetCli>true</IncludeDotNetCli>
<DotNetCliPackageType>sdk</DotNetCliPackageType>
</PropertyGroup>

<PropertyGroup Condition="'$(UseDotNetCliVersionFromGlobalJson)' == 'true'">
<GlobalJsonContent>$([System.IO.File]::ReadAllText('$(RepoRoot)global.json'))</GlobalJsonContent>
<DotNetCliVersion>$([System.Text.RegularExpressions.Regex]::Match($(GlobalJsonContent), '(%3F&lt;="dotnet": ").*(%3F=")'))</DotNetCliVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(HelixCommand)' == ''">
<HelixCommand Condition="'$(InstallDevCerts)' == 'true' and '$(BrowserHost)' != 'windows'">dotnet dev-certs https &amp;&amp; </HelixCommand>

<!-- on windows `dotnet dev-certs https shows a dialog, so instead install the certificate with powershell -->
<HelixCommand Condition="'$(InstallDevCerts)' == 'true' and '$(BrowserHost)' == 'windows'">powershell -command &quot;New-SelfSignedCertificate -FriendlyName &#39;ASP.NET Core HTTPS development certificate&#39; -DnsName @(&#39;localhost&#39;) -Subject &#39;CN = localhost&#39; -KeyAlgorithm RSA -KeyLength 2048 -HashAlgorithm sha256 -CertStoreLocation &#39;Cert:\CurrentUser\My&#39; -TextExtension @(&#39;2.5.29.37={text}1.3.6.1.5.5.7.3.1&#39;,&#39;1.3.6.1.4.1.311.84.1.1={hex}02&#39;,&#39;2.5.29.19={text}&#39;) -KeyUsage DigitalSignature,KeyEncipherment&quot; &amp;&amp; </HelixCommand>

<!--
For Windows we need to use "call", since the command is going to be called from a batch script created by Helix.
We "exit /b" at the end of RunTests.cmd. Helix runs some other commands after ours within the batch script,
so if we don't use "call", then we cause the parent script to exit, and anything after will not be executed.
-->
<HelixCommand Condition="'$(TargetsWindows)' == 'true' or '$(BrowserHost)' == 'windows'">call RunTests.cmd</HelixCommand>
<HelixCommand Condition="'$(TargetsWindows)' == 'true' or '$(BrowserHost)' == 'windows'">$(HelixCommand)call RunTests.cmd</HelixCommand>
<HelixCommand Condition="('$(TargetsWindows)' == 'true' or '$(BrowserHost)' == 'windows') and '$(IncludeHelixCorrelationPayload)' == 'true'">$(HelixCommand) --runtime-path %HELIX_CORRELATION_PAYLOAD%</HelixCommand>
<HelixCommand Condition="'$(TargetsWindows)' != 'true' and '$(BrowserHost)' != 'windows'">./RunTests.sh</HelixCommand>

<HelixCommand Condition="'$(TargetsWindows)' != 'true' and '$(BrowserHost)' != 'windows'">$(HelixCommand)./RunTests.sh</HelixCommand>
<HelixCommand Condition="'$(TargetsWindows)' != 'true' and '$(BrowserHost)' != 'windows' and '$(IncludeHelixCorrelationPayload)' == 'true'">$(HelixCommand) --runtime-path "$HELIX_CORRELATION_PAYLOAD"</HelixCommand>
</PropertyGroup>

Expand Down

0 comments on commit 72936ec

Please sign in to comment.