ASP.NET Core HTTPS development certificate support
* Added support for generating the HTTPS development certificate on the CLI first run experience. * On first run, an HTTPS certificate will be set up on the current user local store. * The environment variable DOTNET_GENERATE_ASPNET_CERTIFICATE can be used to turn the feature off.
This commit is contained in:
parent
661f004b16
commit
ad8f3da826
24 changed files with 395 additions and 3 deletions
|
@ -59,7 +59,9 @@
|
||||||
<CLI_NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-25908-02</CLI_NETStandardLibraryNETFrameworkVersion>
|
<CLI_NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-25908-02</CLI_NETStandardLibraryNETFrameworkVersion>
|
||||||
<SharedHostVersion>$(MicrosoftNETCoreAppPackageVersion)</SharedHostVersion>
|
<SharedHostVersion>$(MicrosoftNETCoreAppPackageVersion)</SharedHostVersion>
|
||||||
<HostFxrVersion>$(MicrosoftNETCoreAppPackageVersion)</HostFxrVersion>
|
<HostFxrVersion>$(MicrosoftNETCoreAppPackageVersion)</HostFxrVersion>
|
||||||
|
<!-- This is the version for ASP.NET packages that the CLI depends on to build, like the
|
||||||
|
component for generating HTTPS certificates on first run. -->
|
||||||
|
<CLI_ASPNET_Version>2.1.0-preview1-27617</CLI_ASPNET_Version>
|
||||||
<AspNetCoreTemplatePackageVersion>2.0.3</AspNetCoreTemplatePackageVersion>
|
<AspNetCoreTemplatePackageVersion>2.0.3</AspNetCoreTemplatePackageVersion>
|
||||||
<AspNetCoreRuntimePackageBrandName>aspnetcore-store</AspNetCoreRuntimePackageBrandName>
|
<AspNetCoreRuntimePackageBrandName>aspnetcore-store</AspNetCoreRuntimePackageBrandName>
|
||||||
<AspNetCoreRuntimePackageFolderName>dev-26623</AspNetCoreRuntimePackageFolderName>
|
<AspNetCoreRuntimePackageFolderName>dev-26623</AspNetCoreRuntimePackageFolderName>
|
||||||
|
|
|
@ -21,6 +21,8 @@
|
||||||
<add key="BlobFeed" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
|
<add key="BlobFeed" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
|
||||||
<add key="templating" value="https://dotnet.myget.org/F/templating/api/v3/index.json" />
|
<add key="templating" value="https://dotnet.myget.org/F/templating/api/v3/index.json" />
|
||||||
<add key="aspnet" value="https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json" />
|
<add key="aspnet" value="https://dotnet.myget.org/F/aspnetcore-release/api/v3/index.json" />
|
||||||
|
<!-- Remove all other 2.0.0 aspnet entries when we start taking new ASP.NET packages -->
|
||||||
|
<add key="aspnet-next" value="https://dotnet.myget.org/F/aspnetcore-dev/api/v3/index.json" />
|
||||||
<add key="websdkfeed" value="https://dotnet.myget.org/F/dotnet-web/api/v3/index.json" />
|
<add key="websdkfeed" value="https://dotnet.myget.org/F/dotnet-web/api/v3/index.json" />
|
||||||
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
|
<add key="cli-deps" value="https://dotnet.myget.org/F/cli-deps/api/v3/index.json" />
|
||||||
<add key="roslyn" value="https://dotnet.myget.org/f/roslyn/api/v3/index.json" />
|
<add key="roslyn" value="https://dotnet.myget.org/f/roslyn/api/v3/index.json" />
|
||||||
|
|
61
src/Microsoft.DotNet.Configurer/AspNetCertificateSentinel.cs
Normal file
61
src/Microsoft.DotNet.Configurer/AspNetCertificateSentinel.cs
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
|
using Microsoft.Extensions.EnvironmentAbstractions;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Configurer
|
||||||
|
{
|
||||||
|
public class AspNetCertificateSentinel : IAspNetCertificateSentinel
|
||||||
|
{
|
||||||
|
public static readonly string SENTINEL = $"{Product.Version}.aspNetCertificateSentinel";
|
||||||
|
|
||||||
|
private readonly IFile _file;
|
||||||
|
private readonly IDirectory _directory;
|
||||||
|
|
||||||
|
private string _dotnetUserProfileFolderPath;
|
||||||
|
|
||||||
|
private string SentinelPath => Path.Combine(_dotnetUserProfileFolderPath, SENTINEL);
|
||||||
|
|
||||||
|
public AspNetCertificateSentinel(CliFolderPathCalculator cliFallbackFolderPathCalculator) :
|
||||||
|
this(
|
||||||
|
CliFolderPathCalculator.DotnetUserProfileFolderPath,
|
||||||
|
FileSystemWrapper.Default.File,
|
||||||
|
FileSystemWrapper.Default.Directory)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
internal AspNetCertificateSentinel(string dotnetUserProfileFolderPath, IFile file, IDirectory directory)
|
||||||
|
{
|
||||||
|
_file = file;
|
||||||
|
_directory = directory;
|
||||||
|
_dotnetUserProfileFolderPath = dotnetUserProfileFolderPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Exists()
|
||||||
|
{
|
||||||
|
return _file.Exists(SentinelPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CreateIfNotExists()
|
||||||
|
{
|
||||||
|
if (!Exists())
|
||||||
|
{
|
||||||
|
if (!_directory.Exists(_dotnetUserProfileFolderPath))
|
||||||
|
{
|
||||||
|
_directory.CreateDirectory(_dotnetUserProfileFolderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
_file.CreateEmptyFile(SentinelPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,8 @@ namespace Microsoft.DotNet.Configurer
|
||||||
private INuGetCachePrimer _nugetCachePrimer;
|
private INuGetCachePrimer _nugetCachePrimer;
|
||||||
private INuGetCacheSentinel _nugetCacheSentinel;
|
private INuGetCacheSentinel _nugetCacheSentinel;
|
||||||
private IFirstTimeUseNoticeSentinel _firstTimeUseNoticeSentinel;
|
private IFirstTimeUseNoticeSentinel _firstTimeUseNoticeSentinel;
|
||||||
|
private IAspNetCertificateSentinel _aspNetCertificateSentinel;
|
||||||
|
private IAspNetCoreCertificateGenerator _aspNetCoreCertificateGenerator;
|
||||||
private string _cliFallbackFolderPath;
|
private string _cliFallbackFolderPath;
|
||||||
private readonly IEnvironmentPath _pathAdder;
|
private readonly IEnvironmentPath _pathAdder;
|
||||||
|
|
||||||
|
@ -23,6 +25,8 @@ namespace Microsoft.DotNet.Configurer
|
||||||
INuGetCachePrimer nugetCachePrimer,
|
INuGetCachePrimer nugetCachePrimer,
|
||||||
INuGetCacheSentinel nugetCacheSentinel,
|
INuGetCacheSentinel nugetCacheSentinel,
|
||||||
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
||||||
|
IAspNetCertificateSentinel aspNetCertificateSentinel,
|
||||||
|
IAspNetCoreCertificateGenerator aspNetCoreCertificateGenerator,
|
||||||
IEnvironmentProvider environmentProvider,
|
IEnvironmentProvider environmentProvider,
|
||||||
IReporter reporter,
|
IReporter reporter,
|
||||||
string cliFallbackFolderPath,
|
string cliFallbackFolderPath,
|
||||||
|
@ -31,6 +35,8 @@ namespace Microsoft.DotNet.Configurer
|
||||||
_nugetCachePrimer = nugetCachePrimer;
|
_nugetCachePrimer = nugetCachePrimer;
|
||||||
_nugetCacheSentinel = nugetCacheSentinel;
|
_nugetCacheSentinel = nugetCacheSentinel;
|
||||||
_firstTimeUseNoticeSentinel = firstTimeUseNoticeSentinel;
|
_firstTimeUseNoticeSentinel = firstTimeUseNoticeSentinel;
|
||||||
|
_aspNetCertificateSentinel = aspNetCertificateSentinel;
|
||||||
|
_aspNetCoreCertificateGenerator = aspNetCoreCertificateGenerator;
|
||||||
_environmentProvider = environmentProvider;
|
_environmentProvider = environmentProvider;
|
||||||
_reporter = reporter;
|
_reporter = reporter;
|
||||||
_cliFallbackFolderPath = cliFallbackFolderPath;
|
_cliFallbackFolderPath = cliFallbackFolderPath;
|
||||||
|
@ -59,6 +65,31 @@ namespace Microsoft.DotNet.Configurer
|
||||||
_nugetCachePrimer.PrimeCache();
|
_nugetCachePrimer.PrimeCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(ShouldGenerateAspNetCertificate())
|
||||||
|
{
|
||||||
|
GenerateAspNetCertificate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GenerateAspNetCertificate()
|
||||||
|
{
|
||||||
|
_aspNetCoreCertificateGenerator.GenerateAspNetCoreDevelopmentCertificate();
|
||||||
|
|
||||||
|
_reporter.WriteLine();
|
||||||
|
_reporter.WriteLine(LocalizableStrings.AspNetCertificateInstalled);
|
||||||
|
|
||||||
|
_aspNetCertificateSentinel.CreateIfNotExists();
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool ShouldGenerateAspNetCertificate()
|
||||||
|
{
|
||||||
|
var generateAspNetCertificate =
|
||||||
|
_environmentProvider.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true);
|
||||||
|
|
||||||
|
return ShouldRunFirstRunExperience() &&
|
||||||
|
generateAspNetCertificate &&
|
||||||
|
!_aspNetCertificateSentinel.Exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddPackageExecutablePath()
|
private void AddPackageExecutablePath()
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Configurer
|
||||||
|
{
|
||||||
|
public interface IAspNetCertificateSentinel
|
||||||
|
{
|
||||||
|
bool Exists();
|
||||||
|
|
||||||
|
void CreateIfNotExists();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Configurer
|
||||||
|
{
|
||||||
|
public interface IAspNetCoreCertificateGenerator
|
||||||
|
{
|
||||||
|
void GenerateAspNetCoreDevelopmentCertificate();
|
||||||
|
}
|
||||||
|
}
|
|
@ -137,7 +137,7 @@ A command is running to populate your local package cache to improve restore spe
|
||||||
<data name="FailedToPrimeCacheError" xml:space="preserve">
|
<data name="FailedToPrimeCacheError" xml:space="preserve">
|
||||||
<value>Failed to prime the NuGet cache. {0} failed with: {1}</value>
|
<value>Failed to prime the NuGet cache. {0} failed with: {1}</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="UnauthorizedAccessMessage" xml:space="preserve">
|
<data name="UnauthorizedAccessMessage" xml:space="preserve">
|
||||||
<value>Permission denied to modify the '{0}' folder.
|
<value>Permission denied to modify the '{0}' folder.
|
||||||
|
|
||||||
Here are some options to fix this error:
|
Here are some options to fix this error:
|
||||||
|
@ -147,4 +147,9 @@ Here are some options to fix this error:
|
||||||
3. Copy the .NET Core SDK to a non-protected location and use it from there.
|
3. Copy the .NET Core SDK to a non-protected location and use it from there.
|
||||||
</value>
|
</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
<data name="AspNetCertificateInstalled" xml:space="preserve">
|
||||||
|
<value>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
|
@ -57,6 +57,15 @@ Tuto chybu můžete opravit pomocí některé z těchto možností:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Im Folgenden finden Sie einige Optionen, um diesen Fehler zu beheben:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Estas son algunas opciones para corregir este error:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Voici quelques options pour corriger cette erreur :
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Ecco alcune opzioni per correggere questo errore:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Here are some options to fix this error:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Here are some options to fix this error:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Oto kilka opcji naprawiania tego błędu:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Aqui estão algumas opções para consertar este erro:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Here are some options to fix this error:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Bu hatayı düzeltmek için bazı seçenekler:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Here are some options to fix this error:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
|
@ -57,6 +57,15 @@ Here are some options to fix this error:
|
||||||
</target>
|
</target>
|
||||||
<note />
|
<note />
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="AspNetCertificateInstalled">
|
||||||
|
<source>ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</source>
|
||||||
|
<target state="new">ASP.NET Core
|
||||||
|
------------
|
||||||
|
Installed ASP.NET Core HTTPS development certificate. For more information go to https://go.microsoft.com/fwlink/?linkid=84805</target>
|
||||||
|
<note />
|
||||||
|
</trans-unit>
|
||||||
</body>
|
</body>
|
||||||
</file>
|
</file>
|
||||||
</xliff>
|
</xliff>
|
16
src/dotnet/AspNetCoreCertificateGenerator.cs
Normal file
16
src/dotnet/AspNetCoreCertificateGenerator.cs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Copyright (c) .NET Foundation and contributors. All rights reserved.
|
||||||
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.DeveloperCertificates.XPlat;
|
||||||
|
using Microsoft.DotNet.Configurer;
|
||||||
|
|
||||||
|
namespace Microsoft.DotNet.Cli
|
||||||
|
{
|
||||||
|
public class AspNetCoreCertificateGenerator : IAspNetCoreCertificateGenerator
|
||||||
|
{
|
||||||
|
public void GenerateAspNetCoreDevelopmentCertificate()
|
||||||
|
{
|
||||||
|
CertificateGenerator.GenerateAspNetHttpsCertificate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -141,6 +141,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
ConfigureDotNetForFirstTimeUse(
|
ConfigureDotNetForFirstTimeUse(
|
||||||
nugetCacheSentinel,
|
nugetCacheSentinel,
|
||||||
firstTimeUseNoticeSentinel,
|
firstTimeUseNoticeSentinel,
|
||||||
|
new AspNetCertificateSentinel(cliFallbackFolderPathCalculator),
|
||||||
cliFallbackFolderPathCalculator,
|
cliFallbackFolderPathCalculator,
|
||||||
hasSuperUserAccess);
|
hasSuperUserAccess);
|
||||||
|
|
||||||
|
@ -204,6 +205,7 @@ namespace Microsoft.DotNet.Cli
|
||||||
private static void ConfigureDotNetForFirstTimeUse(
|
private static void ConfigureDotNetForFirstTimeUse(
|
||||||
INuGetCacheSentinel nugetCacheSentinel,
|
INuGetCacheSentinel nugetCacheSentinel,
|
||||||
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
IFirstTimeUseNoticeSentinel firstTimeUseNoticeSentinel,
|
||||||
|
IAspNetCertificateSentinel aspNetCertificateSentinel,
|
||||||
CliFolderPathCalculator cliFolderPathCalculator,
|
CliFolderPathCalculator cliFolderPathCalculator,
|
||||||
bool hasSuperUserAccess)
|
bool hasSuperUserAccess)
|
||||||
{
|
{
|
||||||
|
@ -219,10 +221,13 @@ namespace Microsoft.DotNet.Cli
|
||||||
nugetPackagesArchiver,
|
nugetPackagesArchiver,
|
||||||
nugetCacheSentinel,
|
nugetCacheSentinel,
|
||||||
cliFolderPathCalculator);
|
cliFolderPathCalculator);
|
||||||
|
var aspnetCertificateGenerator = new AspNetCoreCertificateGenerator();
|
||||||
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
var dotnetConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
nugetCachePrimer,
|
nugetCachePrimer,
|
||||||
nugetCacheSentinel,
|
nugetCacheSentinel,
|
||||||
firstTimeUseNoticeSentinel,
|
firstTimeUseNoticeSentinel,
|
||||||
|
aspNetCertificateSentinel,
|
||||||
|
aspnetCertificateGenerator,
|
||||||
environmentProvider,
|
environmentProvider,
|
||||||
Reporter.Output,
|
Reporter.Output,
|
||||||
cliFolderPathCalculator.CliFallbackFolderPath,
|
cliFolderPathCalculator.CliFallbackFolderPath,
|
||||||
|
|
|
@ -55,6 +55,7 @@
|
||||||
<PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
|
<PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.3.0" />
|
||||||
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
|
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
|
||||||
<PackageReference Include="System.Private.DataContractSerialization" Version="4.3.0" />
|
<PackageReference Include="System.Private.DataContractSerialization" Version="4.3.0" />
|
||||||
|
<PackageReference Include="Microsoft.AspNetCore.DeveloperCertificates.XPlat" Version="$(CLI_ASPNET_Version)" />
|
||||||
<PackageReference Include="Microsoft.Win32.Registry" Version="4.3.0" />
|
<PackageReference Include="Microsoft.Win32.Registry" Version="4.3.0" />
|
||||||
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)" />
|
<PackageReference Include="Microsoft.Build" Version="$(MicrosoftBuildPackageVersion)" />
|
||||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(MicrosoftDotNetPlatformAbstractionsPackageVersion)" />
|
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="$(MicrosoftDotNetPlatformAbstractionsPackageVersion)" />
|
||||||
|
|
|
@ -18,6 +18,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
private Mock<INuGetCachePrimer> _nugetCachePrimerMock;
|
private Mock<INuGetCachePrimer> _nugetCachePrimerMock;
|
||||||
private Mock<INuGetCacheSentinel> _nugetCacheSentinelMock;
|
private Mock<INuGetCacheSentinel> _nugetCacheSentinelMock;
|
||||||
private Mock<IFirstTimeUseNoticeSentinel> _firstTimeUseNoticeSentinelMock;
|
private Mock<IFirstTimeUseNoticeSentinel> _firstTimeUseNoticeSentinelMock;
|
||||||
|
private Mock<IAspNetCertificateSentinel> _aspNetCertificateSentinelMock;
|
||||||
|
private Mock<IAspNetCoreCertificateGenerator> _aspNetCoreCertificateGeneratorMock;
|
||||||
private Mock<IEnvironmentProvider> _environmentProviderMock;
|
private Mock<IEnvironmentProvider> _environmentProviderMock;
|
||||||
private Mock<IReporter> _reporterMock;
|
private Mock<IReporter> _reporterMock;
|
||||||
private Mock<IEnvironmentPath> _pathAdder;
|
private Mock<IEnvironmentPath> _pathAdder;
|
||||||
|
@ -27,6 +29,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock = new Mock<INuGetCachePrimer>();
|
_nugetCachePrimerMock = new Mock<INuGetCachePrimer>();
|
||||||
_nugetCacheSentinelMock = new Mock<INuGetCacheSentinel>();
|
_nugetCacheSentinelMock = new Mock<INuGetCacheSentinel>();
|
||||||
_firstTimeUseNoticeSentinelMock = new Mock<IFirstTimeUseNoticeSentinel>();
|
_firstTimeUseNoticeSentinelMock = new Mock<IFirstTimeUseNoticeSentinel>();
|
||||||
|
_aspNetCertificateSentinelMock = new Mock<IAspNetCertificateSentinel>();
|
||||||
|
_aspNetCoreCertificateGeneratorMock = new Mock<IAspNetCoreCertificateGenerator>();
|
||||||
_environmentProviderMock = new Mock<IEnvironmentProvider>();
|
_environmentProviderMock = new Mock<IEnvironmentProvider>();
|
||||||
_reporterMock = new Mock<IReporter>();
|
_reporterMock = new Mock<IReporter>();
|
||||||
_pathAdder = new Mock<IEnvironmentPath>();
|
_pathAdder = new Mock<IEnvironmentPath>();
|
||||||
|
@ -48,6 +52,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -71,6 +77,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -94,6 +102,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -114,6 +124,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -134,6 +146,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -153,6 +167,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -172,6 +188,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -194,6 +212,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -213,6 +233,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -233,6 +255,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -256,6 +280,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -281,6 +307,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
new FakeCreateWillExistNuGetCacheSentinel(false, true),
|
new FakeCreateWillExistNuGetCacheSentinel(false, true),
|
||||||
new FakeCreateWillExistFirstTimeUseNoticeSentinel(false),
|
new FakeCreateWillExistFirstTimeUseNoticeSentinel(false),
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -300,6 +328,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -327,6 +357,8 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Object,
|
_nugetCachePrimerMock.Object,
|
||||||
_nugetCacheSentinelMock.Object,
|
_nugetCacheSentinelMock.Object,
|
||||||
_firstTimeUseNoticeSentinelMock.Object,
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
_environmentProviderMock.Object,
|
_environmentProviderMock.Object,
|
||||||
_reporterMock.Object,
|
_reporterMock.Object,
|
||||||
CliFallbackFolderPath,
|
CliFallbackFolderPath,
|
||||||
|
@ -337,6 +369,104 @@ namespace Microsoft.DotNet.Configurer.UnitTests
|
||||||
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
_nugetCachePrimerMock.Verify(r => r.PrimeCache(), Times.Never);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void It_does_not_generate_the_aspnet_https_development_certificate_if_the_sentinel_exists()
|
||||||
|
{
|
||||||
|
_aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(true);
|
||||||
|
|
||||||
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
|
_nugetCachePrimerMock.Object,
|
||||||
|
_nugetCacheSentinelMock.Object,
|
||||||
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
|
_environmentProviderMock.Object,
|
||||||
|
_reporterMock.Object,
|
||||||
|
CliFallbackFolderPath,
|
||||||
|
_pathAdder.Object);
|
||||||
|
|
||||||
|
dotnetFirstTimeUseConfigurer.Configure();
|
||||||
|
|
||||||
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never);
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void It_does_not_generate_the_aspnet_https_development_certificate_when_the_user_has_set_the_DOTNET_SKIP_FIRST_TIME_EXPERIENCE_environment_variable()
|
||||||
|
{
|
||||||
|
_aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(false);
|
||||||
|
_environmentProviderMock
|
||||||
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_SKIP_FIRST_TIME_EXPERIENCE", false))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
|
_nugetCachePrimerMock.Object,
|
||||||
|
_nugetCacheSentinelMock.Object,
|
||||||
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
|
_environmentProviderMock.Object,
|
||||||
|
_reporterMock.Object,
|
||||||
|
CliFallbackFolderPath,
|
||||||
|
_pathAdder.Object);
|
||||||
|
|
||||||
|
dotnetFirstTimeUseConfigurer.Configure();
|
||||||
|
|
||||||
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never);
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void It_does_not_generate_the_aspnet_https_development_certificate_when_the_user_has_set_the_DOTNET_GENERATE_ASPNET_CERTIFICATE_environment_variable()
|
||||||
|
{
|
||||||
|
_aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(false);
|
||||||
|
_environmentProviderMock
|
||||||
|
.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true))
|
||||||
|
.Returns(false);
|
||||||
|
|
||||||
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
|
_nugetCachePrimerMock.Object,
|
||||||
|
_nugetCacheSentinelMock.Object,
|
||||||
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
|
_environmentProviderMock.Object,
|
||||||
|
_reporterMock.Object,
|
||||||
|
CliFallbackFolderPath,
|
||||||
|
_pathAdder.Object);
|
||||||
|
|
||||||
|
dotnetFirstTimeUseConfigurer.Configure();
|
||||||
|
|
||||||
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)), Times.Never);
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Never);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void It_generates_the_aspnet_https_development_certificate_if_the_sentinel_does_not_exist()
|
||||||
|
{
|
||||||
|
_aspNetCertificateSentinelMock.Setup(n => n.Exists()).Returns(false);
|
||||||
|
_environmentProviderMock.Setup(e => e.GetEnvironmentVariableAsBool("DOTNET_GENERATE_ASPNET_CERTIFICATE", true))
|
||||||
|
.Returns(true);
|
||||||
|
|
||||||
|
var dotnetFirstTimeUseConfigurer = new DotnetFirstTimeUseConfigurer(
|
||||||
|
_nugetCachePrimerMock.Object,
|
||||||
|
_nugetCacheSentinelMock.Object,
|
||||||
|
_firstTimeUseNoticeSentinelMock.Object,
|
||||||
|
_aspNetCertificateSentinelMock.Object,
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Object,
|
||||||
|
_environmentProviderMock.Object,
|
||||||
|
_reporterMock.Object,
|
||||||
|
CliFallbackFolderPath,
|
||||||
|
_pathAdder.Object);
|
||||||
|
|
||||||
|
dotnetFirstTimeUseConfigurer.Configure();
|
||||||
|
|
||||||
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.FirstTimeWelcomeMessage)));
|
||||||
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.NugetCachePrimeMessage)));
|
||||||
|
_reporterMock.Verify(r => r.WriteLine(It.Is<string>(str => str == LocalizableStrings.AspNetCertificateInstalled)));
|
||||||
|
_aspNetCoreCertificateGeneratorMock.Verify(s => s.GenerateAspNetCoreDevelopmentCertificate(), Times.Once);
|
||||||
|
}
|
||||||
|
|
||||||
private class FakeCreateWillExistFirstTimeUseNoticeSentinel : IFirstTimeUseNoticeSentinel
|
private class FakeCreateWillExistFirstTimeUseNoticeSentinel : IFirstTimeUseNoticeSentinel
|
||||||
{
|
{
|
||||||
private bool _exists;
|
private bool _exists;
|
||||||
|
|
Loading…
Reference in a new issue