Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET Core 1.1 Docker容器无法验证HTTPS连接_C#_Docker_Asp.net Core - Fatal编程技术网

C# ASP.NET Core 1.1 Docker容器无法验证HTTPS连接

C# ASP.NET Core 1.1 Docker容器无法验证HTTPS连接,c#,docker,asp.net-core,C#,Docker,Asp.net Core,只有在构建部署我的容器时,我才会遇到这个问题。当在我的机器上本地运行它时,这不是问题 证书只是一个自签名证书,因为(如果有人好奇)我们的docker基础设施有一个负载平衡器,它拥有所有“受信任”的证书,负载平衡器与容器建立连接 基本上,对容器的所有HTTPS请求都会失败,并记录以下内容: Now listening on: https://*:443 10/19/2017 6:26:50 PMApplication started. Press Ctrl+C to shut down. 10/1

只有在构建部署我的容器时,我才会遇到这个问题。当在我的机器上本地运行它时,这不是问题

证书只是一个自签名证书,因为(如果有人好奇)我们的docker基础设施有一个负载平衡器,它拥有所有“受信任”的证书,负载平衡器与容器建立连接

基本上,对容器的所有HTTPS请求都会失败,并记录以下内容:

Now listening on: https://*:443
10/19/2017 6:26:50 PMApplication started. Press Ctrl+C to shut down.
10/19/2017 6:27:30 PMdbug: Microsoft.AspNetCore.Server.Kestrel[1]
10/19/2017 6:27:30 PM      Connection id "0HL8N93RRUEON" started.
10/19/2017 6:27:30 PMinfo: HttpsConnectionFilter[1]
10/19/2017 6:27:30 PM      Failed to authenticate HTTPS connection.
10/19/2017 6:27:30 PMSystem.IO.IOException: The handshake failed due to an unexpected packet format.
10/19/2017 6:27:30 PM   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
10/19/2017 6:27:30 PM   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
10/19/2017 6:27:30 PM--- End of stack trace from previous location where exception was thrown ---
10/19/2017 6:27:30 PM   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
10/19/2017 6:27:30 PM   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
10/19/2017 6:27:30 PM   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
10/19/2017 6:27:30 PM   at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
10/19/2017 6:27:30 PM   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
10/19/2017 6:27:30 PM--- End of stack trace from previous location where exception was thrown ---
10/19/2017 6:27:30 PM   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
10/19/2017 6:27:30 PM   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
10/19/2017 6:27:30 PM   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
10/19/2017 6:27:30 PM   at Microsoft.AspNetCore.Server.Kestrel.Https.HttpsConnectionFilter.<OnConnectionAsync>d__6.MoveNext()
10/19/2017 6:27:30 PMdbug: Microsoft.AspNetCore.Server.Kestrel[10]
10/19/2017 6:27:30 PM      Connection id "0HL8N93RRUEON" disconnecting.
10/19/2017 6:27:30 PMdbug: Microsoft.AspNetCore.Server.Kestrel[7]
10/19/2017 6:27:30 PM      Connection id "0HL8N93RRUEON" sending FIN.
10/19/2017 6:27:30 PMdbug: Microsoft.AspNetCore.Server.Kestrel[8]
10/19/2017 6:27:30 PM      Connection id "0HL8N93RRUEON" sent FIN with status "0".
10/19/2017 6:27:30 PMdbug: Microsoft.AspNetCore.Server.Kestrel[2]
10/19/2017 6:27:30 PM      Connection id "0HL8N93RRUEON" stopped.
10/19/2017 6:27:39 PMdbug: Microsoft.AspNetCore.Server.Kestrel[1]
10/19/2017 6:27:39 PM      Connection id "0HL8N93RRUEOO" started.
10/19/2017 6:27:39 PMinfo: HttpsConnectionFilter[1]
10/19/2017 6:27:39 PM      Failed to authenticate HTTPS connection.
10/19/2017 6:27:39 PMSystem.IO.IOException: The handshake failed due to an unexpected packet format.
10/19/2017 6:27:39 PM   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
10/19/2017 6:27:39 PM   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
10/19/2017 6:27:39 PM--- End of stack trace from previous location where exception was thrown ---
10/19/2017 6:27:39 PM   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
10/19/2017 6:27:39 PM   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
10/19/2017 6:27:39 PM   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
10/19/2017 6:27:39 PM   at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
10/19/2017 6:27:39 PM   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
10/19/2017 6:27:39 PM--- End of stack trace from previous location where exception was thrown ---
10/19/2017 6:27:39 PM   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
10/19/2017 6:27:39 PM   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
10/19/2017 6:27:39 PM   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
10/19/2017 6:27:39 PM   at Microsoft.AspNetCore.Server.Kestrel.Https.HttpsConnectionFilter.<OnConnectionAsync>d__6.MoveNext()
10/19/2017 6:27:39 PMdbug: Microsoft.AspNetCore.Server.Kestrel[10]
10/19/2017 6:27:39 PM      Connection id "0HL8N93RRUEOO" disconnecting.
10/19/2017 6:27:39 PMdbug: Microsoft.AspNetCore.Server.Kestrel[7]
10/19/2017 6:27:39 PM      Connection id "0HL8N93RRUEOO" sending FIN.
10/19/2017 6:27:39 PMdbug: Microsoft.AspNetCore.Server.Kestrel[8]
10/19/2017 6:27:39 PM      Connection id "0HL8N93RRUEOO" sent FIN with status "0".
10/19/2017 6:27:39 PMdbug: Microsoft.AspNetCore.Server.Kestrel[2]
10/19/2017 6:27:39 PM      Connection id "0HL8N93RRUEOO" stopped.
10/19/2017 6:27:48 PMdbug: Microsoft.AspNetCore.Server.Kestrel[1]
10/19/2017 6:27:48 PM      Connection id "0HL8N93RRUEOP" started.
10/19/2017 6:27:48 PMinfo: HttpsConnectionFilter[1]
10/19/2017 6:27:48 PM      Failed to authenticate HTTPS connection.
10/19/2017 6:27:48 PMSystem.IO.IOException: The handshake failed due to an unexpected packet format.
10/19/2017 6:27:48 PM   at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
10/19/2017 6:27:48 PM   at System.Net.Security.SslState.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
10/19/2017 6:27:48 PM--- End of stack trace from previous location where exception was thrown ---
10/19/2017 6:27:48 PM   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
10/19/2017 6:27:48 PM   at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
10/19/2017 6:27:48 PM   at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result)
10/19/2017 6:27:48 PM   at System.Net.Security.SslStream.EndAuthenticateAsServer(IAsyncResult asyncResult)
10/19/2017 6:27:48 PM   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
10/19/2017 6:27:48 PM--- End of stack trace from previous location where exception was thrown ---
10/19/2017 6:27:48 PM   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
10/19/2017 6:27:48 PM   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
10/19/2017 6:27:48 PM   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
10/19/2017 6:27:48 PM   at Microsoft.AspNetCore.Server.Kestrel.Https.HttpsConnectionFilter.<OnConnectionAsync>d__6.MoveNext()
10/19/2017 6:27:48 PMdbug: Microsoft.AspNetCore.Server.Kestrel[10]
10/19/2017 6:27:48 PM      Connection id "0HL8N93RRUEOP" disconnecting.
10/19/2017 6:27:48 PMdbug: Microsoft.AspNetCore.Server.Kestrel[7]
10/19/2017 6:27:48 PM      Connection id "0HL8N93RRUEOP" sending FIN.
10/19/2017 6:27:48 PMdbug: Microsoft.AspNetCore.Server.Kestrel[8]
10/19/2017 6:27:48 PM      Connection id "0HL8N93RRUEOP" sent FIN with status "0".
10/19/2017 6:27:48 PMdbug: Microsoft.AspNetCore.Server.Kestrel[2]
10/19/2017 6:27:48 PM      Connection id "0HL8N93RRUEOP" stopped.
检查负载平衡器是否真的发送https请求(不是http w/o s…)
public static void Main(string[] args)
{
    Console.Title = "IdentityServer";
    string certPass = Environment.GetEnvironmentVariable("CertificatePassword");

    var host = new WebHostBuilder()
        .UseKestrel(options =>
        {
            options.UseHttps(@"IdentityServer4Auth.pfx", certPass);
        })
        .UseUrls("https://*:443")
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<Startup>()
        .Build();

    host.Run();
}
FROM microsoft/aspnetcore:1.1.2
ARG source
WORKDIR /app
COPY . .
RUN curl -o **omitted** --insecure
RUN echo **omitted** >> /etc/ca-certificates.conf && update-ca-certificates

# Expose port 443 for the application.
EXPOSE 443
ENTRYPOINT ["dotnet", "/app/USBIdentityServer.dll"]