title: DockerFile: Generate SSL certificate
body: <p>I am trying to create a signed ssl certificate when building up the image. But the cert.pfx file was not created. If the container was created and placing the same code to create the certificate, the file generated</p>
  
  <pre><code>.
  
  
      FROM microsoft/aspnetcore:2.0 AS base
  WORKDIR /app
  EXPOSE 1445
  EXPOSE 44358
  
  FROM build AS publish
  RUN dotnet publish IdentityServer4WithDocker.csproj -c Release -o /app
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app .
  ENTRYPOINT ["dotnet", "IdentityServer4WithDocker.dll"]
  
  
  ENV certPassword 1234
  
  # Use opnssl to generate a self signed certificate cert.pfx with password $env:certPassword
  RUN openssl genrsa -des3 -passout pass:1234 -out server.key 2048
  RUN openssl rsa -passin pass:1234 -in server.key -out server.key
  RUN openssl req -sha256 -new -key server.key -out server.csr -subj '/CN=localhost'
  RUN openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
  RUN openssl pkcs12 -export -out cert.pfx -inkey server.key -in server.crt -certfile server.crt -passout pass:1234
  
  FROM microsoft/aspnetcore-build:2.0 AS build
  WORKDIR /src
  COPY IdentityServer4WithDocker/IdentityServer4WithDocker.csproj IdentityServer4WithDocker/
  RUN dotnet restore IdentityServer4WithDocker/IdentityServer4WithDocker.csproj
  COPY . .
  WORKDIR /src/IdentityServer4WithDocker
  RUN dotnet build IdentityServer4WithDocker.csproj -c Release -o /app
  </code></pre>