依赖Kestrel.Https 1.0.0-rc1-final不支持框架DNSCore,版本=v5.0



我正在尝试将https配置到我的Kestrel服务器,以便使用dnxcore50Ubuntu 14上运行。

但是当我添加一个依赖项到:

"Microsoft.AspNet.Server.Kestrel.Https":"1.0.0-rc1-final"

我试图恢复我的包裹,我收到了这样的消息:

依赖Kestrel.Https 1.0.0-rc1-final不支持框架DNSCore,版本=v5.0

如果我转到windows并使用dnx451并添加相同的依赖项,效果会很好。

但是,如果我不能在带有dnxcore50Ubuntu上使用Kestrel.Https,我如何使用dnxcore50Ubuntu配置Https?

这是因为Kestrel的HTTPS版本只针对RC1上的完整.NET框架:https://www.nuget.org/packages/Microsoft.AspNet.Server.Kestrel.Https/1.0.0-rc1-final.

自RC2 Kestrel.Https将以netstandard1.3为目标:https://github.com/aspnet/KestrelHttpServer/blob/dev/src/Microsoft.AspNetCore.Server.Kestrel.Https/project.json#L20.

因此,解决方案是等待RC2下降,或者使用MyGet中的出血RC2位。

如今Kestrel已经支持HTTPS:

以下是自1.0.0:版本以来支持它的库

https://www.nuget.org/packages/Microsoft.AspNetCore.Server.Kestrel.Https/

要在代码中实现它,请在初始化asp.net核心应用程序的main中添加UseHttps作为选项

这里有一个如何做的示例!

    public static void Main(string[] args)
    {
        var host = new WebHostBuilder()
            .UseKestrel(options =>
            {
                // options.ThreadCount = 4;
                options.NoDelay = true;
                options.UseHttps("testCert.pfx", "testPassword");
                options.UseConnectionLogging();
            })
            .UseUrls("http://localhost:5000", "https://localhost:5001")
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseStartup<Startup>()
            .Build();
        // The following section should be used to demo sockets
        //var addresses = application.GetAddresses();
        //addresses.Clear();
        //addresses.Add("http://unix:/tmp/kestrel-test.sock");
        host.Run();
    }

下面还有一个来自样本的链接

https://github.com/aspnet/KestrelHttpServer/blob/dev/samples/SampleApp/Startup.cs#L37-L43

最新更新