4
프로세스 간 통신을 위해 NetNamedPipe를 사용하는 WCF 서비스가 있으며 보안을 추가하고 싶습니다. 모든 것이 보안없이 훌륭하게 작동하지만, tranport 보안을 사용할 때 "InvalidCredentialException : 서버가 클라이언트 자격 증명을 거부했습니다"예외가 발생합니다. 저를 도와주세요?NetNamedPipe에 대한 보안을 올바르게 설정하는 방법은 무엇입니까?
코드 샘플 :
var netPipeBinding = new NetNamedPipeBinding() { MaxReceivedMessageSize = 2147483647, SendTimeout = TimeSpan.FromMinutes(10), ReceiveTimeout = TimeSpan.FromMinutes(10) };
netPipeBinding.ReaderQuotas.MaxDepth = 2147483647;
netPipeBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
netPipeBinding.ReaderQuotas.MaxArrayLength = 2147483647;
netPipeBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
netPipeBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
netPipeBinding.Security.Mode = NetNamedPipeSecurityMode.Transport;
netPipeBinding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
var host = new ServiceHost(typeof(MainService));
var netPipeEA = new EndpointAddress(new Uri("net.pipe://MyProject/ServerSide"));
var contractDescription = ContractDescription.GetContract(typeof (IMainService), typeof (MainService));
host.AddServiceEndpoint(new ServiceEndpoint(contractDescription, netPipeBinding, netPipeEA));
host.Opened += HostOnOpened;
host.Open();
...
... 당신이 때문에
private void HostOnOpened(object sender, EventArgs eventArgs)
{
var netPipeBinding = new NetNamedPipeBinding() { MaxReceivedMessageSize = 2147483647, SendTimeout = TimeSpan.FromMinutes(10), ReceiveTimeout = TimeSpan.FromMinutes(10) };
netPipeBinding.ReaderQuotas.MaxDepth = 2147483647;
netPipeBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
netPipeBinding.ReaderQuotas.MaxArrayLength = 2147483647;
netPipeBinding.ReaderQuotas.MaxBytesPerRead = 2147483647;
netPipeBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
netPipeBinding.Security.Mode = NetNamedPipeSecurityMode.Transport;
netPipeBinding.Security.Transport.ProtectionLevel = ProtectionLevel.EncryptAndSign;
DuplexChannelFactory<IMainService> channelFactory = new DuplexChannelFactory<IMainService>(new InstanceContext(new CalbackHandler()), netPipeBinding,
new EndpointAddress(IMainService));
var proxy = channelFactory.CreateChannel();
proxy.DoPing();
}
은 "localhost"를,이 경우에는
http://msdn.microsoft.com/en-us/library/windows/desktop/aa365600(v=vs.85).aspx –
어떤 "보안"을 추가하려고합니까? netNamedPipeBinding을 사용하면 전송이 OS 커널의 제어하에 커널 메모리를 통해 짧은 홉일 뿐이므로 전송 연결 ('ProtectionLevel.EncryptAndSign')을 통해 데이터 개인 정보 및 데이터 무결성을 추가 할 필요가 없습니다. 거기에 숨어있는 남자는 이미 당신의 기계를 소유하고 있습니다. –
질문 : 누구든지 여하튼 내가 보내거나받는 것을들을 수 있습니까? 그렇다면 보안이 있어야합니다. – user2126375