Owin selbst host-Konsole-Anwendung mit https-Unterstützung (kein web-api, keine SignalR)

Mit SslStream und Steckdose, die ich entwickelt habe, eine https-web-server von Grund auf neu.
Kann ich anwenden, um ein Zertifikat der stream von C# - code und befassen sich mit den Anfragen.

Hab ich allerdings nicht herausfinden, wie dies mit Owin.
Hat jemand wissen, wie man um ein Zertifikat zu binden, um eine selbst gehostete Konsole-Anwendung?

Beispiel:

//Bind the below certificate to Owin host
var certificate = new X509Certificate2("server.pfx", "password");

Bitte beachten Sie die bestehenden Owin host-code unten für details:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 = $"http://localhost:{port}";
            using (WebApp.Start<Startup>(url))
            {
                Console.WriteLine($"Hosted: {url}");
                Console.ReadLine();
            }
        }
    }

    public class Startup
    {
        private IAppBuilder app;
        public void Configuration(IAppBuilder app)
        {
#if DEBUG
            app.UseErrorPage();
#endif

            app.Use(new Func<AppFunc, AppFunc>(next => (async env =>
            {
                Console.WriteLine("Begin Request");
                foreach (var i in env.Keys)
                {
                    Console.WriteLine($"{i}\t={(env[i] == null ? "null" : env[i].ToString())}\t#\t{(env[i] == null ? "null" : env[i].GetType().FullName)}");
                }
                if (next != null)
                {
                    await next.Invoke(env);
                }
                else
                {
                    Console.WriteLine("Process Complete");
                }
                Console.WriteLine("End Request");
            })));

            app.UseWelcomePage("/");

            this.app = app;
        }


    }

}

InformationsquelleAutor mind1n | 2015-11-19

Schreibe einen Kommentar