Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS2017 Docker debugging failed: Failed to create the certificate #99

Open
MichaelSL opened this Issue May 8, 2018 · 61 comments

Comments

Projects
None yet
@MichaelSL
Copy link

MichaelSL commented May 8, 2018

Created new NET Core MVC application on clean installed Windows 10 Pro 1803.

Trying to start debugging and get:
Adding the certificate to the Trusted Root Certficates store failed with the following error: Failed to create the certificate.

Already created a local account, removed %userprofile%\vsdbg and %userprofile%\onecoremsvsmon

VS info:

Version 15.8.0 Preview 1.0
VisualStudio.15.Preview/15.8.0-pre.1.0+27705.0
Microsoft .NET Framework
Version 4.7.03056

Installed Version: Community

Application Insights Tools for Visual Studio Package   8.12.10405.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017   15.0.40502.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services   15.7.31476
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017   5.2.60419.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0   15.0.40424.0
Azure App Service Tools v3.0.0

Azure Data Lake Node   1.0
This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio   2.3.3000.2
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   15.0.40424.0
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.3.3000.2
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   2.8.0-beta6-62830-08. Commit Hash: e595ee276d14e14bfb3eb323fb57f2aa668bddea
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents   1.0
Fabric Diagnostic Events

GitHub.VisualStudio   2.2.0.10
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

Microsoft Azure HDInsight Azure Node   2.3.3000.2
HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service   2.3.3000.2
Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio   2.1
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service   2.3.3000.2
Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node   1.0
Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools   2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10420.2

Microsoft Continuous Delivery Tools for Visual Studio   0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager   1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers   1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager   4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension   1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension   1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools   15.1.61804.210
Microsoft SQL Server Data Tools

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   15.7.20419.2003
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools   2.8.0-beta6-62830-08. Commit Hash: e595ee276d14e14bfb3eb323fb57f2aa668bddea
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1   15.7.0.0.  Commit Hash: 16ecf5a30ad868d183c58e4a71a71c23d4ed3ba9.
Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package   1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers   1.0
Visual Studio Tools for Containers`

@haniamr haniamr self-assigned this May 8, 2018

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented May 8, 2018

@MichaelSL thanks for reporting. Which version of dotnet core 2.1 did you install? and that local account you created, is it an admin account? If not, can you make sure it has write permissions to these folders:

  • %APPDATA%\Microsoft\UserSecrets
  • %APPDATA%\ASP.NET

Thanks!

@hbiarge

This comment has been minimized.

Copy link

hbiarge commented May 13, 2018

I can reproduce this one.
In a solution with two Asp.Net Core projects, both of them with support for docker. If both have an UserSecretId it works perfectly, but if you delete the UserSecretId for one of the projects (in the .csproj file) you get this Failed to create the certificate error.
Tested in two different solutions with the same result. Visual Studio 2017 Professional 15.7.1
Hope this helps.

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented May 14, 2018

@hbiarge thanks for sharing, if that's the case, then the error is expected since we use the UserSecretId to store the local certificate export password, so when trying to export it into the container it fails if that's not found.

@Eltargrim

This comment has been minimized.

Copy link

Eltargrim commented May 15, 2018

I too have this issue, and it is not with multiple projects. On a clean install all I do is create a new project with both Docker and Azure Active Directory authentication and the project will not run, with this error.

I've tried getting a project with both Docker and Azure Active Directory a number of ways, always failing. If I template both out of the gate I receive this certificate error. If I try without anything and add on Docker Support and Azure Active Directory I cannot get it work, but receive different errors.

@MichaelSL

This comment has been minimized.

Copy link
Author

MichaelSL commented May 16, 2018

Sorry for the late answer. Debug started after recent Docker update.

  • NET Core version: 2.1.200
  • User is admin and has permissions to both directories.
  • No User Secrets used - just a new web application project.

Everything is fixed for me. @Eltargrim did you manage to resolve your issue?

@jbt00000

This comment has been minimized.

Copy link

jbt00000 commented May 18, 2018

I'm getting the same issue....
Visual Studio Enterprise 15.7.1
.NET Core 2.0
ASP.NET Core Web Application
Docker (OS=Linux)

Happens on first run... Without adding 1 line of code.

Running VS as an admin... hoping that will elevate permissions to get around the adding problem, does not fix the issue.

@Bartmax

This comment has been minimized.

Copy link

Bartmax commented May 21, 2018

having the same error here. multiple proj, only 1 with docker support. running vs as elevated.

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented May 21, 2018

@jbt00000 are you seeing that error on a .NET 2.0 app?
@Bartmax You do not have to run VS as an admin, how about the user used in Docker Shared Drives? Can you make sure it has permissions to:

  • %APPDATA%\Microsoft\UserSecrets
  • %APPDATA%\ASP.NET
@albertusgouzalixrelements

This comment has been minimized.

Copy link

albertusgouzalixrelements commented May 22, 2018

Hi there, same here, I have ensured that the local user has read / write permission to:

  • %APPDATA%\Microsoft\UserSecrets
  • %APPDATA%\ASP.NET

however it also failed on creating the certificate. It ran fine if I create the web application without an authentication, however it not able to create the certificate when I use the web app with individual user account.

i haven't make any changes to the project itself, just create one from the template and try to run it on docker.

@jbt00000

This comment has been minimized.

Copy link

jbt00000 commented May 22, 2018

I downgraded to VS 15.6.7 (which I needed to do because SSDT doesn't work on 15.7.1...) and now it works.

@albertusgouzalixrelements

This comment has been minimized.

Copy link

albertusgouzalixrelements commented May 22, 2018

sounds like an issue with the latest version of VS and the preview, will try the earlier version, thanks @jbt00000

@haniamr haniamr added the bug label May 23, 2018

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented May 23, 2018

I managed to reproduce the issue. A workaround you can try is to remove the following from docker-compose.override.yml: (the below is an example)

version: '3.4'
services:
  webapplication3:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80   <=========
      - ASPNETCORE_HTTPS_PORT=44392
    ports:
      - "51493:80"
      - "44392:443"           <========== (The mapping for 443 not the second line specifically)
    volumes:
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
@albertusgouzalixrelements

This comment has been minimized.

Copy link

albertusgouzalixrelements commented May 24, 2018

Hi @haniamr
The workaround seems to work great, thanks for that.

I have also confirm that the previous version of Visual Studio works as well, it seems only affecting 15.7.1 and 15.7.2 at this stage. and @MichaelSL has confirmed Version 15.8.0 Preview 1.0 works as well, so i guess this should be fixed on the next release?

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented May 25, 2018

@albertusgouzalixrelements thanks for the confirmation, yes it will be fixed on the next release.

@alihaidrz

This comment has been minimized.

Copy link

alihaidrz commented May 27, 2018

Version 15.8.0 Preview 1.0 has the same issue i just downloaded it and it has the exact same behavior

@albertusgouzalixrelements

This comment has been minimized.

Copy link

albertusgouzalixrelements commented May 27, 2018

@alihaidrz MichaelSL are able to get around the issue with Version 15.8.0 Preview 1.0, have you tried to update the docker to the latest version?

@alihaidrz

This comment has been minimized.

Copy link

alihaidrz commented May 28, 2018

yes docker has the later version here is the information for visual studio:

Microsoft Visual Studio Enterprise 2017 Preview
Version 15.8.0 Preview 1.1

@zslocum

This comment has been minimized.

Copy link

zslocum commented May 31, 2018

I'm still having this issue as well with the current Edge version of Docker and Visual Studio Preview 15.8.0 Preview 2.0

Other than modifying the docker-compose.override.yml file as described above I have been unable to find a workaround.

OutSorcerer pushed a commit to OutSorcerer/AspNetCoreAndAngularSSRInsideDockerIssue that referenced this issue Jun 12, 2018

@dazinator

This comment has been minimized.

Copy link

dazinator commented Jun 17, 2018

@haniamr - so is the workaround for now to remove https completely? I assume that is what you mean by remove the mappings?

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented Jul 5, 2018

@dazinator yes that's correct. The issue here is that scaffolding should only generate the certificate mappings for dotnet core 2.1 and not 2.0, as that's the only supported version for https in containers at the moment.

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented Jul 5, 2018

I'll close the issue since it's fixed in 15.8 Preview 3 (latest public preview), please let me know if you're still facing it and I can investigate further.

@haniamr haniamr closed this Jul 5, 2018

@arebelong

This comment has been minimized.

Copy link

arebelong commented Jul 16, 2018

Hi, the issue continue to exist in 15.8 Preview 4. I have created a new project and I get

Adding the certificate to the Trusted Root Certficates store failed with the following error: Failed to create the certificate." when I try to run the application

These are the settings used for the new application. Please note I needed to update the nuget to latest version for the application to run.

image

I am able to make the application work by updating the docker.compose file as suggested previously.

This compose will work.

version: '3.4'

services:
webapplication22:
environment:
- ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://+:80
ports:
- "54894:80"
volumes:
- ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
- ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

@MarkDixonTech

This comment has been minimized.

Copy link

MarkDixonTech commented Aug 9, 2018

I am also getting a similar error, also in 15.8 Preview 5, after creating a new Web Application project with Docker Support.

Adding the certificate to the Trusted Root Certificates store failed with the following error:
Failed with a critical error.

The error occurs during Step 4 of 4

Step 4/4 : EXPOSE 44373

As above, I am able to get it working by removing the SSL port mapping

@Heurazio

This comment has been minimized.

Copy link

Heurazio commented Aug 11, 2018

Same Problem with the latest Version 2.1

@simeyla

This comment has been minimized.

Copy link

simeyla commented Aug 25, 2018

Can someone explain exactly what Visual Studio is trying to do.
I know what a development certificate is, but is that what the problem is here?
Can't I just install it manually?

I'm completely new to Docker and it is quickly becoming insanely frustrating trying to put all the pieces together.

I removed the line from override, and the EXPOSE line and still getting:

Adding the certificate to the Trusted Root Certficates store failed with the following error:
Failed with a critical error.

I have VS 15.8 RTM. I don't even know if this is a Visual Studio or Docker issue.

@Heurazio

This comment has been minimized.

Copy link

Heurazio commented Aug 25, 2018

I was able to solve the problem by recreating the project. Somehow, the certificate and/or it's thumbprint got deleted/corrupted but there still was the https entry in the docker-compose.override.yml. After recreating the project and copy over all needed files, everything worked fine again.

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented Sep 12, 2018

Re-opening since the issue is still happening, although I believe it might be a different scenario.

So here is what VS is doing when you F5 an ASP.NET Core Web App 2.1 with Https and docker enabled:

  1. Check if the development certificate exists and trusted or not
  2. If (1) is false, then prompt the user to trust the certificate
  3. Export the certificate to %APPDATA%\ASP.NET\https{WebAppName}.pfx
  4. Save the password in the user store in %APPDATA%\Microsoft\UserSecrets

I'm unable to repro what you're seeing on a clean machine with VS 15.8.4, so please provide me with the following:

  1. The original issue was on ASP.NET Core 2.0 apps with authentication enabled, is it still the same case? Or is it a 2.1 app?
  2. Do you get the prompt to trust the certificate then the failure message? Or is it the failure message directly?
  3. If you get the prompt first, do you see this Windows prompt warning you about trusting the certificate?
    image
  4. Do you have a value for the property "UserSecretsId" in the web project?
  5. Please run the following commands and share with me the results:
    • dotnet dev-certs https --trust --check
    • echo Trust check: %errorlevel%
    • dotnet dev-certs https --trust -ep "%APPDATA%\ASP.NET\https\{WebAppName}.pfx" -p TestPassword
    • echo Trust/Export: %errorlevel%
    • cd "{Directory where your .csproj lives}"
    • dotnet user-secrets set Kestrel:Certificates:Development:Password TestPassword
  6. In your current user certificate store, do you have a certificate named "ASP.NET Core HTTP development certificate" with the following properties?
    image
    It should be both under "Personal" and "Trusted Root Certification Authorities".

@arebelong I have a question about your repro steps, when you created a project while enabling docker support in VS 15.8, did you get a docker-compose project? Or you had to add it using the context-menu -> Add Container Orchestrator support?

@haniamr haniamr reopened this Sep 12, 2018

@krotkiske

This comment has been minimized.

Copy link

krotkiske commented Sep 12, 2018

@krotkiske

This comment has been minimized.

Copy link

krotkiske commented Sep 12, 2018

@krotkiske

This comment has been minimized.

Copy link

krotkiske commented Sep 12, 2018

@krotkiske

This comment has been minimized.

Copy link

krotkiske commented Sep 12, 2018

@MarkDixonTech

This comment has been minimized.

Copy link

MarkDixonTech commented Sep 19, 2018

I also do not have a certificate under either personal or trusted by that name. it created a certificate called localhost.

On Tue, Sep 11, 2018 at 9:34 PM Hani Amr @.***> wrote: Re-opening since the issue is still happening, although I believe it might be a different scenario. So here is what VS is doing when you F5 an ASP.NET Core Web App 2.1 with Https and docker enabled: 1. Check if the development certificate exists and trusted or not 2. If (1) is false, then prompt the user to trust the certificate 3. Export the certificate to %APPDATA%\ASP.NET\https{WebAppName}.pfx 4. Save the password in the user store in %APPDATA%\Microsoft\UserSecrets I'm unable to repro what you're seeing on a clean machine with VS 15.8.4, so please provide me with the following: 1. The original issue was on ASP.NET Core 2.0 apps with authentication enabled, is it still the same case? Or is it a 2.1 app? 2. Do you get the prompt to trust the certificate then the failure message? Or is it the failure message directly? 3. If you get the prompt first, do you see this Windows prompt warning you about trusting the certificate? [image: image] https://user-images.githubusercontent.com/5480153/45396550-0cb90d00-b5f1-11e8-99ff-985dcfac263b.png 4. Do you have a value for the property "UserSecretsId" in the web project? 5. Please run the following commands and share with me the results: - dotnet dev-certs https --trust --check - echo Trust check: %errorlevel% - dotnet dev-certs https --trust -ep "%APPDATA%\ASP.NET\https{WebAppName}.pfx" -p TestPassword - echo Trust/Export: %errorlevel% - cd "{Directory where your .csproj lives}" - dotnet user-secrets set Kestrel:Certificates:Development:Password TestPassword 6. In your current user certificate store, do you have a certificate named "ASP.NET Core HTTP development certificate" with the following properties? [image: image] https://user-images.githubusercontent.com/5480153/45396482-acc26680-b5f0-11e8-9d0a-4cd83445d712.png It should be both under "Personal" and "Trusted Root Certification Authorities". @arebelong https://github.com/arebelong I have a question about your repro steps, when you created a project while enabling docker support in VS 15.8, did you get a docker-compose project? Or you had to add it using the context-menu -> Add Container Orchestrator support? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#99 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AKlKmGgHWlpnZUFQQ7iHk8l4Mvz9inoEks5uaGSsgaJpZM4T2DOZ .

The Issued To and Issued By will be localhost but the Friendly Name will be ASP.NET Core HTTPS Development certificate

@MarkDixonTech

This comment has been minimized.

Copy link

MarkDixonTech commented Sep 19, 2018

I have managed to get this working by manually importing the file at %APPDATA%\ASP.NET\https{WebAppName}.pfx into my certifcate store at CurrentUser/Personal/Certifcates

I also ran the following:

  • dotnet dev-certs https --trust -ep "%APPDATA%\ASP.NET\https{WebAppName}.pfx"
    -p TestPassword

    - cd "{Directory where your .csproj lives}"
    - dotnet user-secrets set Kestrel:Certificates:Development:Password
    

I also noticed that the location is was writing the pfx file to was %AppData%\Roaming

I'm wondering whether this is related. Maybe roaming profile is used when logging in using Microsoft Account and this explains why only some users are seeing this.

@MarkDixonTech

This comment has been minimized.

Copy link

MarkDixonTech commented Sep 19, 2018

And if anyone is trying to do this on Service Fabric it had to go into the Local Machine certificate store instead

@krotkiske

This comment has been minimized.

Copy link

krotkiske commented Sep 19, 2018

@arielmoraes

This comment has been minimized.

Copy link

arielmoraes commented Sep 19, 2018

Sorry for the late response, but it seems that the certificate is not being created in the correct folder, in my machine when I start a new project using HTTPS the folder which is expected to contain the certificate is empty.

When we run dev-certs to create a certificate it creates a general development certificate as I can tell, when we use HTTPS with docker what is the expected flow? Does each application need its own certificate thus the examples here are always like applicationName.pfx?

@haniamr

This comment has been minimized.

Copy link
Member

haniamr commented Sep 26, 2018

@krotkiske thanks for your feedback, I believe your issue might be permissions related, how different is the machine configuration (i.e. domain joined or not, user accounts, etc.) where it doesn't work and the one it does?

@MarkDixonTech thanks for pointing that out, it depends on where your %APPDATA% points but the roaming folder shouldn't be a problem, I've tested it on both roaming and local and it works fine on my machine.

@arielmoraes thanks for getting back on this, I've explained the whole scenario in this comment for what the tooling is attempting to do, it's a bit different from the normal dev-certs scenario for a vanilla ASP.NET 2.1 app since we have to export the certificate and volume mount it in the container.

Since the issue is not reproducible on my setup, please feel free to drop me an email and I'll be happy to arrange a Skype call and troubleshoot the issue further on your machine.

@mparker

This comment has been minimized.

Copy link

mparker commented Oct 2, 2018

While trying to figure out problems trying to run a Service Fabric project locally (no docker involved), I came across this thread. I got past it and thought I'd add my comment, in case it helps anyone.

The fix for me was to create a new user account with no spaces in the name. I'm guessing that whatever commands that are run in the background don't use quotes around the path, so references to %APPDATA% fail.

@gianlazz

This comment has been minimized.

Copy link

gianlazz commented Oct 10, 2018

I would also like to chime in and report that I've followed along with the instructions and am still at a blocking point in development on this issue with VS 15.8.6

@RicardoArndt

This comment has been minimized.

Copy link

RicardoArndt commented Oct 20, 2018

Hello guys, i'm brazilian sorry my english.
I resolve my problem creating new account in windows but not with spaces in account name, the folder "Users/{yourname}" not have spaces example "Ricardo Arndt" -> Error, "RicardoArndt" -> OK

@bwateratmsft

This comment has been minimized.

Copy link
Contributor

bwateratmsft commented Oct 22, 2018

@RicardoArndt, @mparker This is very helpful info. I found where the bug might be, we did a separate fix that is going into VS15.9 that I suspect may have also fixed this issue. If you are able, can you try the latest 15.9 Preview build from here? You can install it side-by-side with your existing install, and remove it if you no longer need it.

@PrefixAM

This comment has been minimized.

Copy link

PrefixAM commented Oct 22, 2018

VS 15.8.7, .Net core 2.1. Had "cannot find container to attach" issue. Container related issue was resolved by moving the project from the subfolder to a root level, Debug, then moving back (as it described here: https://developercommunity.visualstudio.com/content/problem/314882/single-project-docker-experience-breaks-if-using-s.html )
Once it was fixed, got certificate related issue. Tried to delete \ regenerate certificate, delete various temporary folders. Fixed the issue by right click on the project -> Manage User Secrets. It created an empty secrets.json file. Then just ran Debug and the issue is gone. A certificate was added, also VS has added "Kestrel:Certificates:Development:Password" into secrets.json.

@leandroferreira1985

This comment has been minimized.

Copy link

leandroferreira1985 commented Oct 27, 2018

@krotkiske I was facing the same issue here. I solved it changing my user's folder name (C:\Users\UserName). The folder had a "space" character, for example: C:\Users*User Name*. Once I replace the folder's name to C:\Users*UserName* the Visual Studio was able to generate the certificate automatically.
Take a look in the physical path for %APPDATA%, it will start at C:\Users.... and verify if your user contains space or other special character.
Is it is the case, this video explain how to rename the folder correctly. If you are using Docker for Windows, maybe will be necessary reset credentials at "Shared Drivers" and restart Docker.
Hope it helps.

@rmccabe24

This comment has been minimized.

Copy link

rmccabe24 commented Nov 7, 2018

I am also having this issue in VS2017.

Taken from Output window (Docker):

========== Pulling Images ==========
Pulling missing Docker images. To cancel this download, close the command prompt window. To disable image auto-pull, see Tools > Options > Container Tools.
docker pull gcr.io/google-appengine/aspnetcore:2.1
docker pull completed
========== Debugging ==========
docker-compose  -f "C:\Users\sp4_rm\Desktop\Mb CODE\Mb.Platform.WebApi\src\docker-compose.yml" -f "C:\Users\sp4_rm\Desktop\Mb CODE\Mb.Platform.WebApi\src\obj\Docker\docker-compose.vs.debug.g.yml" -p dockercompose16382350260440979265 --no-ansi config
The DOCKER_REGISTRY variable is not set. Defaulting to a blank string.
services:
  mb.platform.webApi:
    build:
      context: C:\Users\sp4_rm\Desktop\Mb CODE\Mb.Platform.WebApi\src
      dockerfile: Mb.Platform.WebApi/Dockerfile
    entrypoint: tail -f /dev/null
    environment:
      ASPNETCORE_ENVIRONMENT: Development
      ASPNETCORE_HTTPS_PORT: '44335'
      ASPNETCORE_URLS: https://+:443;http://+:80
      DOTNET_USE_POLLING_FILE_WATCHER: '1'
      NUGET_FALLBACK_PACKAGES: /root/.nuget/fallbackpackages
    image: mbplatformapi:dev
    labels:
      com.microsoft.visualstudio.debuggee.arguments: ' --additionalProbingPath /root/.nuget/packages
        --additionalProbingPath /root/.nuget/fallbackpackages  bin/Debug/netcoreapp2.1/Mb.Platform.WebApi.dll'
      com.microsoft.visualstudio.debuggee.killprogram: /bin/bash -c "if PID=$$(pidof
        -x dotnet); then kill $$PID; fi"
      com.microsoft.visualstudio.debuggee.program: dotnet
      com.microsoft.visualstudio.debuggee.workingdirectory: /app
    ports:
    - published: 52645
      target: 80
    - published: 44335
      target: 443
    volumes:
    - C:\Users\sp4_rm\Desktop\Mb CODE\Mb.Platform.WebApi\src\Mb.Platform.WebApi:/app:rw
    - C:\Users\sp4_rm\vsdbg\vs2017u5:/remote_debugger:ro
    - C:\Users\sp4_rm\AppData\Roaming\ASP.NET\Https:/root/.aspnet/https:ro
    - C:\Users\sp4_rm\AppData\Roaming\Microsoft\UserSecrets:/root/.microsoft/usersecrets:ro
    - C:\Program Files\dotnet\sdk\NuGetFallbackFolder:/root/.nuget/fallbackpackages:ro
    - C:\Users\sp4_rm\.nuget\packages:/root/.nuget/packages:ro
version: '3.4'
docker ps --filter "status=running" --filter "name=dockercompose16382350260440979265_mb.platform.webApi_" --format {{.ID}} -n 1
58b173a7188b

Build succeeded and then the Docker stuff failed.

VS version: 15.8.4

@marriottr

This comment has been minimized.

Copy link

marriottr commented Dec 7, 2018

Everything was good for me until I installed VS2019 V16.0.0 Preview 1.0. Now I get this problem in VS2017 as well and can no longer run any netcore web project.

...

However this worked for me.
https://www.hanselman.com/blog/DevelopingLocallyWithASPNETCoreUnderHTTPSSSLAndSelfSignedCerts.aspx

@Zenexer

This comment has been minimized.

Copy link

Zenexer commented Jan 23, 2019

Can confirm this error appears if VS2019 preview is installed. Can't find a way around it. I think when I run dotnet, it's the 2.2 3.0 preview that's being invoked, and of course that cert is already trusted.

Edit: Said 2.2 preview initially; meant 3.0

@Zenexer

This comment has been minimized.

Copy link

Zenexer commented Jan 23, 2019

I've uninstalled VS2019, uninstalled every version of .NET Core SDK, reinstalled the latest stable verison of .NET Core SDK, and still I get this error. I can't figure out the issue. The certificate gets installed just fine--Visual Studio gives an error regardless. Even if it's already installed, nope, error.

@marriottr

This comment has been minimized.

Copy link

marriottr commented Jan 23, 2019

@Zenexer

This comment has been minimized.

Copy link

Zenexer commented Jan 25, 2019

I've opened a bug report in the Visual Studio Developer Community regarding side-by-side installation of VS15 and VS16: https://developercommunity.visualstudio.com/content/problem/435856/side-by-side-installation-with-visual-studio-2019.html

@Zenexer

This comment has been minimized.

Copy link

Zenexer commented Jan 25, 2019

First attempt the following:

  1. Right-click on your ASP.NET Core project in Solution Explorer.
  2. Choose Manage User Secrets.
  3. secrets.json will open. There should be a Kestrel:Certificates:Development:Password key. If there isn't, you found the culprit. Save your project, close secrets.json, and run the project. The entry should now be added to secrets.json automatically.

If that doesn't work, you'll need to fully restore VS15. This isn't really a workaround since it doesn't permit usage of VS16, but if you'd like to get VS15 working again, it will do the trick:

  1. Uninstall both Visual Studio 2017 and Visual Studio 2019 Preview.
  2. In an administrative PowerShell terminal, run dotnet nuget locals all --clear and nuget locals all --clear. The latter won't succeed if you don't have NuGet installed separately, but either one should theoretically be sufficient, so you can ignore the error.
  3. Uninstall all versions of .NET Core, both preview and stable releases.
  4. Reboot.
  5. Double-check Program Files for any NuGet, Visual Studio, and .NET Core artifacts. Delete anything you find.
  6. Install Visual Studio 2017.
  7. If the version of .NET Core installed with Visual Studio 2017 doesn't match the version your project requires, additionally install both the x64 and x86 .NET Core SDKs for the corresponding stable version. They're separate installers; make sure you get both unless your solution only supports one architecture.
@SychevIgor

This comment has been minimized.

Copy link

SychevIgor commented Feb 21, 2019

The same issue for me:
But it's not working for a one project, but if I will a new project- it will work.
Running under administrator- didn't solve the issue.
I had never try vs 2019 previews or rtm on this machine.

Microsoft Visual Studio Professional 2017
Version 15.9.7
VisualStudio.15.Release/15.9.7+28307.423
Microsoft .NET Framework
Version 4.7.03190

Installed Version: Professional

Application Insights Tools for Visual Studio Package 8.14.20131.1
Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.9.04012.0
ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.8.31590
Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017 5.2.60913.0
For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.9.03024.0
Azure App Service Tools v3.0.0

Azure Functions and Web Jobs Tools 15.9.02046.0
Azure Functions and Web Jobs Tools

Azure Kubernetes Service Publish Tools (Preview) 1.0
Tools for configuring and publishing to Azure Kubernetes Services

C# Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents 1.0
Fabric Diagnostic Events

JavaScript Language Service 2.0
JavaScript Language Service

Microsoft Azure Service Fabric Tools for Visual Studio 2.4
Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.0.0

Microsoft Continuous Delivery Tools for Visual Studio 0.4
Simplifying the configuration of Azure DevOps pipelines from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft Library Manager 1.0
Install client-side libraries easily to any web project

Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

NuGet Package Manager 4.6.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0
ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0
ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 15.1.61901.24070
Microsoft SQL Server Data Tools

TypeScript Tools 15.9.20918.2001
TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.10.0-beta2-63501-03+b9fb1610c87cccc8ceb74a770dba261a58e39c4a
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.2 for F# 4.5 15.8.0.0. Commit Hash: 6e26c5bacc8c4201e962f5bdde0a177f82f88691.
Microsoft Visual F# Tools 10.2 for F# 4.5

Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Containers 1.0
Visual Studio Tools for Containers

Visual Studio Tools for Kubernetes 1.0
Visual Studio Tools for Kubernetes

@danielwgrech

This comment has been minimized.

Copy link

danielwgrech commented Mar 6, 2019

It's happening on my machine and also on 2 of my other colleagues'. We have a .Net Core 2.2 application, and the issue is only when we run it in Docker through Visual Studio 2017 (v15.9.7). We've deleted the "localhost" certificate from both the "Trusted Root Certification Authorities" and "Personal" folders. Visual Studio then prompts to install and trust the certificates, and it seems to do so successfully (I can find the "localhost" certificate again in both places), but then gives the error:

"Adding the certificate to the Trusted Root Certificates store failed with the following error: Failed to create the certificate."

I noticed that Visual Studio is creating a "UserSecretsId" property under "PropertyGroup" in the project file, which my colleagues don't have. How is this secret supposed to make sense for everyone working on the project? And what is its purpose?

While writing this comment, I went to run it again, and it actually worked somehow. All I did was comment/uncomment the "UserSecretsId" part, which makes no sense. In the meantime, my colleagues tried the same procedure and do not have a "UserSecretsId" at all.

Also, I've never had VS2019 installed.

@grmallon

This comment has been minimized.

Copy link

grmallon commented Mar 25, 2019

I ran into this for the past few hours following an update to W10 1809 from W10 build 10240. While I was eventually able to get an app deployed, it still wasn't trusting the dev cert.

Upon a rollback to 10240, things are working properly in a non-docker Core 2.2 web app. Will need to try updating to 1709 or 1803 and see how things go.

@bwateratmsft

This comment has been minimized.

Copy link
Contributor

bwateratmsft commented Apr 18, 2019

I found one potential cause for this that would affect docker-compose applications in particular, but can affect others. Please note, this isn't the only possible cause for this error.

One of the steps in setting up the SSL certificate is telling Kestrel what the SSL certificate password is, via user secrets. The command we use is
dotnet user-secrets set Kestrel:Certificates:Development:Password <randomGuid>

It will fail if there is more than one project file within the directory of the web app. For instance, if you chose "Put solution file and project file in same directory", and then added Compose support, you would have the dcproj and the csproj together in the same folder, and dotnet user-secrets gets confused. I've created a bug to address this particular case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.