I had a problem setting up HTTP for the Owin standalone host application. The browser always shows a reset connection error.
I tried to create certificates manually according to this link http://chavli.com/how-to-configure-owin-self-hosted-website-with-ssl/ , but I still get a reset error message on this port. And I checked the Windows event log and there are no error messages.
The application will create the X509 certificate on its own and automatically execute the netsh command.
Without Ssl, the application can correctly display the web page.
Can I run my code below and see if it can work on your computer? Thanks in advance.
You need to add the CertEnroll 1.0 Type Library COM link to compile the code below (vs2015 already contains this COM link in type libraries)
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.InteropServices; using System.Security; using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading.Tasks; using CERTENROLLLib; using Microsoft.Owin.Hosting; using AppFunc = System.Func<System.Collections.Generic.IDictionary<string, object>, System.Threading.Tasks.Task>; namespace Owin.Startup { class Program { static void Main(string[] args) { int port = 8888; string url = $"https://localhost:{port}"; var cert = GetCert("localhost", TimeSpan.FromDays(3650), "devpwd", AppDomain.CurrentDomain.BaseDirectory + "cert.dat"); ActivateCert(cert, port, GetAppId()); using (WebApp.Start<Startup>(url)) { Console.WriteLine($"Hosted: {url}"); Console.ReadLine(); } } static private string GetAppId() { Assembly assembly = Assembly.GetExecutingAssembly();
source share