2015-11-19 7 views
5

एसएसएलस्ट्रीम और सॉकेट के साथ, मैंने स्क्रैच से एक https वेब सर्वर विकसित किया है। मैं सी # कोड से स्ट्रीम में प्रमाण पत्र लागू कर सकता हूं और अनुरोधों से निपट सकता हूं।https समर्थन के साथ ओविन स्वयं होस्ट कंसोल एप्लिकेशन (कोई वेब एपीआई, कोई सिग्नलआर नहीं)

हालांकि, मुझे यह नहीं पता था कि ओविन के साथ ऐसा कैसे किया जाए। क्या कोई जानता है कि स्वयं होस्ट किए गए कंसोल एप्लिकेशन को प्रमाणपत्र कैसे बांधना है?

उदाहरण:

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

कृपया विवरण के लिए मौजूदा Owin मेजबान नीचे कोड का संदर्भ लें:

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; 
     } 


    } 

} 

उत्तर

0

उसे सर्वर पर निर्भर करता है। यहां HttpListener के साथ ऐसा करने का तरीका बताया गया है: http://katanaproject.codeplex.com/wikipage?title=Selfhosting&referringTitle=Documentation

+0

मैंने कोशिश की लेकिन कनेक्शन रीसेट समस्या मिली। क्या आप निम्नलिखित यूआरएल पर कोड जांचने में मदद कर सकते हैं? धन्यवाद। http://stackoverflow.com/questions/33820731/owin-self-host-ssl-connection-reset – mind1n

संबंधित मुद्दे