简体   繁体   English

如何在不切换到 IIS 的情况下将 SSL 证书附加到我的 asp dot net 网站?

[英]How do I attach an SSL certificate to my asp dot net website without switching to IIS?

I have a certificate, say, "./mysite.pfx" (that I've received from letsenctrypt).我有一个证书,比如“./mysite.pfx”(我从letsenctrypt 收到的)。 To enable HTTPS, I replaced为了启用 HTTPS,我替换了

webBuilder.UseUrls("http://*:80");

with

webBuilder.UseUrls("http://*:80", "https://*:443");

But now if I visit the site it responds with MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT meaning that it cannot find the certificate file (I guess that's because dotnet sends a default).但是现在,如果我访问该站点,它会以 MOZILLA_PKIX_ERROR_SELF_SIGNED_CERT 响应,这意味着它找不到证书文件(我猜这是因为 dotnet 发送了默认值)。 Where do I write the path to the file, how do I configure asp dot net project to use the ssl certificate and https protocol?文件路径在哪里写,如何配置asp dot net项目使用ssl证书和https协议? Windows 10, no IIS. Windows 10,没有 IIS。

You can configure kestrel for your project in CreateHostBuilder method.您可以在 CreateHostBuilder 方法中为您的项目配置 kestrel。 Add SSL port listening (443 by default) and provide your certificate with password.添加 SSL 端口侦听(默认为 443)并为您的证书提供密码。 Also do not forget to add redirection to https from http: Enforce HTTPS in ASP.NET Core另外不要忘记从 http 添加重定向到 https: Enforce HTTPS in ASP.NET Core

public static IHostBuilder CreateHostBuilder(string[] args) =>
    Host.CreateDefaultBuilder(args)
        .ConfigureWebHostDefaults(webBuilder =>
        {
            webBuilder.UseKestrel(options =>
            {
                options.Listen(IPAddress.Any, 80); // http
                options.Listen(IPAddress.Any, 443, listenOptions => // https
                {
                    listenOptions.UseHttps("certificate.pfx", "certificate-password");
                });
            });
            webBuilder.UseStartup<Startup>();
            // other stuff ...
        }

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

相关问题 ASP.NET Core + IIS Express 如何设置 SSL 证书 - ASP.NET Core + IIS Express how to setup SSL Certificate 如何在ASP.NET网站中禁用SSL证书验证 - How to disable SSL certificate validation in ASP.NET website 如何使用IIS 6.0在私人家庭网络中显示ASP.Net网站? - How do I make my ASP.Net website viewable in my private home network using IIS 6.0? 如何将调试器附加到IIS而不是ASP.NET Development Server? - How do I attach the debugger to IIS instead of ASP.NET Development Server? IIS 6中的根目录是什么?如何使ASP.NET网站中的子文件夹之一成为根目录? - what is a root directory in IIS 6 and How do I make one of my subfolder in ASP.NET website the root directory? 我的SSL证书可用于IIS上的新Wordpress网站吗? - Will my SSL certificate work for new Wordpress website on IIS? ASP.NET:如何为我的网站进行IIS索引搜索功能 - ASP.NET : How to do IIS Indexing search feature for my website 如果网站没有数据库,如何重定向到某个页面? IIS,ASP.Net - How do I redirect to a certain page if there is no database for the website??? IIS, ASP.Net 如何在IIS中为asp.net核心应用程序创建具有所有必要设置的新网站? - How do I create a new website in IIS for asp.net core application with all the necessary settings? VBScript / IIS - 如何为特定网站自动设置ASP.NET版本 - VBScript/IIS - How do I automatically set ASP.NET version for a particular website
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM