title: Unable to configure ASP.NET HTTPS endpoint in Windows docker container
body: <p>Getting this error when running ASP.NET Core in Windows docker container...</p>
  
  <pre><code>Unhandled Exception: System.InvalidOperationException: Unable to configure HTTPS endpoint. No server certificate was specified, and the default developer certificate could not be found.
  </code></pre>
  
  <p>I was able to get this to work...</p>
  
  <pre><code>RUN dotnet dev-certs https
  </code></pre>
  
  <p>But I want to install an actual certificate...for now a self-sign certificate but later a real one.</p>
  
  <p>So based on a blog post titled "Import and bind an SSL cert in a Windows container using Powershell", I created the following PS script to run in the container build...</p>
  
  <pre><code>Import-PfxCertificate -FilePath C:\Certificates\xxx.pfx -Password (ConvertTo-SecureString -String "xxxx" -AsPlainText -Force) `
  -CertStoreLocation "Cert:\LocalMachine\My"
  
  $cert = (Get-ChildItem -Path cert:\LocalMachine\My -DNSName "xxx.mydomain.com")[0]
  
  $thumb =  ($cert | Select-Object Thumbprint)."Thumbprint"
  $guid = [guid]::NewGuid().ToString("B")
  
  netsh http add sslcert ipport=0.0.0.0:5001 certhash=$thumb certstorename=MY appid="$guid"
  </code></pre>
  
  <p>This builds fine and seems to install the certificate.  But I get the exception when I try to run the container.  I tried using 443 instead of 5001, same error</p>
  
  <p>Here is my docker file for reference...</p>
  
  <pre><code> escape=`
   FROM xxx/base
   EXPOSE 5000
   EXPOSE 5001
   COPY testing/ /testing
   COPY service/ /Service
   COPY certificates/ /certificates
   COPY scripts/ /scripts
  
   # install certificates
  
   RUN scripts/Install-Container-Certificate.ps1
  
   # configure ASP.NET Core
  
   ENV ASPNETCORE_URLS http://+:80;https://+:443
   EXPOSE 80
   EXPOSE 443
   # RUN dotnet dev-certs https
   # start ASP.NET Core
  
   ENTRYPOINT ["dotnet","/Service/xxxService.dll"]
  </code></pre>
  
  <p>What am I doing wrong?</p>