相关疑难解决方法(0)

Owin自主主机SSL连接重置

在为自主主机Owin控制台应用程序设置HTTP时出现问题.浏览器始终显示连接重置错误.

我已尝试根据此链接http://chavli.com/how-to-configure-owin-self-hosted-website-with-ssl/手动创建证书,但我仍然在该端口上遇到连接重置问题.我已经检查了Windows事件日志,并且没有错误消息.

应用程序将自行创建X509证书并自动运行netsh命令.

没有Ssl,应用程序可以正确显示网页.

任何人都可以在下面运行我的代码并查看它是否可以在您的计算机上运行?提前致谢.

需要添加COM引用CertEnroll 1.0 Type Library来编译下面的代码(vs2015已在类型库中包含此COM引用)

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(); …
Run Code Online (Sandbox Code Playgroud)

ssl https self-hosting netsh owin

5
推荐指数
1
解决办法
2606
查看次数

标签 统计

https ×1

netsh ×1

owin ×1

self-hosting ×1

ssl ×1