2010-11-25 15 views
5

के लिए प्रमाणीकृत डब्ल्यूसीएफ मेरा जीयूआई एप्लीकेशन डब्ल्यूसीएफ के NetNamedPipeBinding का उपयोग करके अपनी बहन विंडोज सेवा को नियंत्रित करता है। मैं अन्य अनुप्रयोगों को अपने जीयूआई आवेदन का प्रतिरूपण करने और मेरी सेवा को नियंत्रित करने से रोकना चाहता हूं।आईपीसी और रिमोट एक्सेस

क्या प्रतिरूपण को रोकने के लिए विंडोज सेवा में जीयूआई एप्लिकेशन प्रमाणीकृत करना आवश्यक है?
और मुझे इसके बारे में कैसे जाना चाहिए?


संपादित करें: दूरस्थ कंप्यूटर को भी दी जाती है कि वे प्रमाणीकृत हैं (सेवा द्वारा विश्वसनीय) सेवा को नियंत्रित करने में सक्षम होना चाहिए, तो मैं एक NetTcpBinding समाप्ति बिंदु जोड़ने की जरूरत है। कोई भी जवाब जो इसे भी शामिल करता है, सहायक होगा।

उत्तर

2

हां, प्रतिरूपण को रोकने के लिए डब्ल्यूसीएफ चैनल को सुरक्षित करना आवश्यक है। जब आप इसे निर्देश देते हैं तो डब्ल्यूसीएफ आपके संचार को स्वचालित रूप से एन्क्रिप्ट कर सकता है, लेकिन आपको प्रमाणीकरण भाग को स्वयं संभालने की आवश्यकता है।

डब्ल्यूसीएफ में संदेशों को सुरक्षित करने के दो तरीके हैं (तीन यदि आप इस तथ्य को गिनते हैं कि आप दोनों एक बार में उपयोग कर सकते हैं)। एक अच्छा उच्च स्तरीय स्पष्टीकरण here है। का उपयोग करने में आप इनमें से किन विधियों पर निर्भर हैं, जिस पर हम बाध्यकारी हैं (आपके पास अलग-अलग बाइंडिंग के लिए अलग-अलग विकल्प होंगे)।

इसके अलावा, सेवा को सुरक्षित करने के प्रत्येक तरीके के लिए आपके पास प्रमाणीकरण प्रमाणिक प्रकारों (वास्तविक साधनों के बीच एक विकल्प होगा जिसमें प्रत्येक इकाई दूसरी पहचान के लिए अपनी पहचान साबित करेगी)। यह बाध्यकारी और सुरक्षा विधि पर भी निर्भर है।

यह देखने के लिए कि प्रत्येक बाध्यकारी के लिए आपके विकल्प क्या हैं, आप इसकी Security संपत्ति देख सकते हैं। यह संपत्ति प्रत्येक बाध्यकारी के लिए एक अलग प्रकार का है (उदा। NetTcpSecurity); आप इसे खोजने के लिए एमएसडीएन या इंटेलिसेन्स की जांच कर सकते हैं।

मैं परिवहन सुरक्षा के साथ NetTcpBinding का उपयोग अब से एक उदाहरण के रूप में करूँगा। पर

var binding = new NetTcpBinding { /* set props here */ }; 
// TLS security with X.509 certificates 
binding.Security.Mode = SecurityMode.Transport; 
binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; 

फिर,:

दोनों सर्वर और ग्राहक भाग में सुरक्षा की स्थापना करने के लिए, आप पहली बार सुरक्षा मोड और प्रमाणीकरण प्रकार के साथ बंधन कॉन्फ़िगर करने के लिए जैसे बनाने और चैनल खोलने, पहले

// Load and set the server certificate 
var serverCertificate = new X509Certificate2(/* parameters here */); 
host.Credentials.ServiceCertificate.Certificate = serverCertificate; 

// You can leave it at that and let Windows validate the client's certificate using 
// the default method (which means that you either need to have added the client's 
// certificate to the server machine's certificate store as "trusted", or rely on chain 
// trust and have the client's certificate signed by a trusted authority. 

// Or, you can use custom validation rules: 
var authentication = host.Credentials.ClientCertificate.Authentication; 
authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; 
authentication.CustomCertificateValidator = new AcceptAnythingCertificateValidator(); 

और ग्राहक के पक्ष (इस उदाहरण भी विशिष्ट है):

var clientCertificate = new X509Certificate2(/* parameters here */); 
var factory = new ChannelFactory<IYourServiceInterface>(binding, endpoint); 
factory.Credentials.ClientCertificate.Certificate = clientCertificate; 

// You can leave it at that and let Windows validate the server's certificate using 
// the default method (which means that you either need to have added the server's 
// certificate to the client machine's certificate store as "trusted", or rely on chain 
// trust and have the server's certificate signed by a trusted authority. 

// Or, you can use custom validation rules: 
var authentication = factory.Credentials.ServiceCertificate.Authentication; 
authentication.CertificateValidationMode = X509CertificateValidationMode.Custom; 
authentication.CustomCertificateValidator = new AcceptAnythingCertificateValidator(); 

var channel = factory.CreateChannel(); 

// Your channel is now ready for use! You can also cast to to IClientChannel 
// to expose some more properties. 
सर्वर साइड (इस उदाहरण से ऊपर बना विकल्प के लिए विशिष्ट है)
+0

आपके महान उत्तर के लिए धन्यवाद। 'MessageCredentialType.Windows' का उपयोग करने पर कोई टिप्पणी? यदि मैं किसी दूरस्थ व्यवस्थापक पर सेवा को नियंत्रित करने के लिए किसी नेटवर्क व्यवस्थापक को अनुमति देना चाहता हूं, तो उपयोगकर्ता को पासवर्ड/उपयोगकर्ता समस्या से निपटने का सबसे आसान तरीका क्या होगा? –

+0

विंडोज सुरक्षा के लिए आवश्यक है कि उपयोगकर्ता किसी डोमेन में Windows उपयोगकर्ता खाते में पहले ही लॉग इन हो और उसे अतिरिक्त उपयोगकर्ता नाम/पासवर्ड की आवश्यकता न हो। इस http://msdn.microsoft.com/en-us/library/ms734769.aspx पर विशेष रूप से देखें (विशेष रूप से इंट्रानेट सेवाओं पर विंडोज सुरक्षा लागू करना) और इस http://msdn.microsoft.com/en-us पर भी देखें उदाहरण के लिए /library/ms730301.aspx। – Jon

+0

धन्यवाद। यह पता लगाया कि यह कैसे और पाया: http://msdn.microsoft.com/en-us/library/ms734673.aspx अब मुझे इसकी जांच करने की आवश्यकता है :) –

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