简体   繁体   English

如何在Windows Server 2016中安装没有IIS的ssl证书?

[英]How to install ssl certificate without IIS in windows server 2016?

I have a project based on asp.net core MVC; 我有一个基于asp.net核心MVC的项目; I want to use an SSL certificate for using https, but when running my project, it didn't show https address. 我想使用SSL证书来使用https,但在运行我的项目时,它没有显示https地址。 I can't use IIS in my windows server.but in windows 10 everything is ok. 我无法在我的Windows服务器中使用IIS。但在Windows 10中一切正常。

I'm trying install SSL certificate in windows server for using https in my project. 我正在尝试在Windows服务器中安装SSL证书,以便在我的项目中使用https。

      public static IWebHost BuildWebHost(string[] args)
        {
            var host = "0.0.0.0";
            var http_port = 40000;
            var https_port = 40001;

            if (args.Length > 0) host = args[0].Trim();
            if (args.Length > 1) http_port = Convert.ToInt32(args[1].Trim());
            if (args.Length > 2) https_port = Convert.ToInt32(args[2].Trim());


            return
            WebHost.CreateDefaultBuilder(args)
                    .UseStartup<Startup>()
                    //
                    .UseKestrel(options =>
                    {
                        options.Limits.MaxRequestBodySize = null;
                        options.Limits.MaxRequestBufferSize = null;
                        options.Limits.MaxRequestHeaderCount = 1000;
                        options.Limits.MaxRequestHeadersTotalSize = 256 * 1024;

                        options.Listen(IPAddress.Parse(host), http_port);

                        using (var store = new X509Store(StoreName.My))
                        {
                            store.Open(OpenFlags.ReadOnly);
                            var certs = store.Certificates.Find(X509FindType.FindBySubjectName, "localhost", false);
                            if (certs.Count > 0)
                            {
                                var certificate = certs[0];

                                options.Listen(IPAddress.Parse(host), https_port, listenOptions =>
                                {
                                    listenOptions.UseHttps(certificate);
                                });
                            }
                        }
                    }).Build();

        }

I expect the output see https://0.0.0.0:40001 , but in windows server I only have http://0.0.0.0:40000 . 我希望输出看到https://0.0.0.0:40001 ,但在Windows服务器中我只有http://0.0.0.0:40000

image of Windows server Windows server Windows服务器Windows服务器的图像

image of Windows 10: Windows 10 Windows 10的图像: Windows 10

Step 1: enable IIS feature in your machine to host. 步骤1:在您的计算机中启用IIS功能以进行托管。 Then go to administrative tool>IIS manager. 然后转到管理工具> IIS管理器。

Step 2 : Select site for which you want to enable ssl. 步骤2:选择要为其启用ssl的站点。

Step 3: In the action panel on right side you will have Edit site and select binding 第3步:在右侧的操作面板中,您将拥有“编辑”站点并选择绑定

Step 4 : in site binding if it already defined, click close or 第4步:如果已经定义了站点绑定,请单击关闭或

1.click add 1.点击添加

2.select https 2.选择https

  1. In ssl certificate, select certificate 在ssl证书中,选择证书

  2. Click ok then close 单击确定然后关闭

Step 5: In connection panel, under site> click site again to display selected website homepage. 步骤5:在连接面板中,在站点>再次单击站点以显示所选的网站主页。

Step 6: In selected website, click on SSL setting 步骤6:在选定的网站中,单击SSL设置

Step 7: In ssl setting, select require ssl and under client certificate select accept. 步骤7:在ssl设置中,选择require ssl并在客户端证书下选择accept。

Step 8: apply 第8步:申请

If I understand things correctly, you are having a hard time using SSL in you development environment. 如果我理解正确,您在开发环境中使用SSL会很困难。 I suggest you look here Enforce HTTPS in ASP.NET CORE . 我建议你看看这里在ASP.NET CORE中强制使用HTTPS At this point on the page, Trust the ASP.NET Core Development Certificates.. ,you'll probably find the solution to your problem. 在页面上的这一点上, 相信ASP.NET核心开发证书.. ,您可能会找到解决问题的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM