Làm thế nào để bạn bật SSL cho dự án trong Visual Studio 2017?Visual Studio 2017 Bật SSL
Trong VS15, tôi có thể chọn Dự án -> Thuộc tính -> Gỡ lỗi -> Bật SSL. Tùy chọn này không có sẵn trong VS2017. Nó di chuyển đến đâu?
Edit:
Tôi thậm chí đã cố gắng chỉnh sửa .\vs\config\applicationhost.config
vô ích:
<listenerAdapters>
<add name="http" />
<add name="https" />
</listenerAdapters>
<sites>
<site name="WebSite1" id="1" serverAutoStart="true">
<application path="/">
<virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\WebSite1" />
</application>
<bindings>
<binding protocol="http" bindingInformation=":8080:localhost" />
</bindings>
</site>
<site name="Filters" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="c:\Users\Ashley\documents\visual studio 2017\Projects\Filters\src\Filters" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:51107:localhost" />
<binding protocol="https" bindingInformation="*:43107:localhost" />
</bindings>
</site>
<siteDefaults>
<logFile logFormat="W3C" directory="%IIS_USER_HOME%\Logs" />
<traceFailedRequestsLogging directory="%IIS_USER_HOME%\TraceLogFiles" enabled="true" maxLogFileSizeKB="1024" />
</siteDefaults>
<applicationDefaults applicationPool="Clr4IntegratedAppPool" />
<virtualDirectoryDefaults allowSubDirConfig="true" />
</sites>
<webLimits />
Edit:
Một tùy chọn khác tôi đã cố gắng, mà chỉ cảm thấy phiền phức, và đánh bại điểm của một IDE, là cấu hình Kestrel để sử dụng HTTPS. Điều này không lý tưởng vì tôi phải xuất bản sao chứng chỉ cho localhost từ IIS và IIS Express vẫn cố gắng tải trang web trên một cổng khác.
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel(options =>
options.UseHttps(new X509Certificate2("path/to/cert.pfx", "password")))
.UseContentRoot(Directory.GetCurrentDirectory())
.UseUrls("http://localhost:5100", "https://localhost:4300")
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
Đáng buồn thay, điều này không hoạt động khi chạy từ VS17. Lần đầu tiên tôi gặp lỗi 502,2 (tôi nghĩ), giờ đây tất cả những gì tôi nhận được là không thể kết nối lỗi trong Chrome. Tôi có thể chạy dotnet run
từ PowerShell và nó hoạt động tốt.
Như một giải pháp, nó thực hiện thủ thuật. Nhưng nó không có vẻ gọn gàng.
Dường như điều này đã thay đổi trong các bản cập nhật gần đây cho Visual Studio 2017 RC? Tôi thấy tùy chọn Enable SSL, và sử dụng nó làm việc tốt cho tôi. Tôi đã phải [thiết lập tài khoản của mình để tin tưởng chứng chỉ IIS] (https://blogs.msdn.microsoft.com/robert_mcmurray/2013/11/15/how-to-trust-the-iis-express-self-signed -chứng chỉ/). –