2011-08-12 8 views
1

나는 SecurityMode.Message를 사용하여 통신을 암호화하는 여러 WCF 서비스를 시작하는 응용 프로그램을 개발했습니다.WCF 인증을위한 SSL Cert

SSL 인증서를 생성하여 특정 저장소, 서버 및 클라이언트에 넣어야하기 때문에 매우 복잡합니다.

  • 사실 (도메인에 있지, 서버가 확실히 도메인에있을 것입니다,하지만 클라이언트
  • 은하지 않습니다

    문제는 프로그램을 사용하는 고객이 있다는 것입니다

그래서 내 최선을 무엇? 난 단지 데이터를 암호화 할 필요가 인증서를 사고 싶어, 내가 올바른 호스트에 연결하고있어 수 있도록 할 필요가 없습니다.

을 나는 '알 ~ 안에 없다. 가장 좋은 경우이지만 일부 특정 사용자가 응용 프로그램을 사용할 것입니다.

서버 측 :

ServiceHost host = new ServiceHost(typeof(MyServiceType)) 
WSHttpBinding binding = new WSHttpBinding 
{ 
    ReaderQuotas = { MaxStringContentLength = int.MaxValue, MaxArrayLength = int.MaxValue,  MaxDepth = int.MaxValue, MaxBytesPerRead = int.MaxValue, MaxNameTableCharCount = int.MaxValue }, 
    MaxReceivedMessageSize = int.MaxValue 
}; 
TimeSpan timeoutSpan = TimeSpan.FromMilliseconds(timeout); 
binding.CloseTimeout = timeoutSpan; 
binding.OpenTimeout = timeoutSpan; 
binding.ReceiveTimeout = timeoutSpan; 
binding.SendTimeout = timeoutSpan; 
binding.ReliableSession.InactivityTimeout = timeoutSpan; 

binding.MaxBufferPoolSize = int.MaxValue; 
binding.Security.Mode = SecurityMode.Message; 
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; 
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; 
host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, ConfigurationManager.AppSettings["Hostname"]); 
host.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; 
host 
.AddServiceEndpoint(services[port], binding, String.Format("http://localhost:{0}", port)); 

클라이언트 측 :

string remoteAddress = String.Format("{0}://{1}:{2}", Tools.GetDescription(accessInfo.ServiceHost.Protocol), accessInfo.ServiceHost.HostName, accessInfo.PortNumber); 


// avoid seralization/deserialization problems with large XML's 
WSHttpBinding binding = new WSHttpBinding(); 
binding.ReaderQuotas.MaxStringContentLength = int.MaxValue; 
binding.ReaderQuotas.MaxArrayLength = int.MaxValue; 
binding.MaxReceivedMessageSize = int.MaxValue; 
binding.ReaderQuotas.MaxStringContentLength = int.MaxValue; 
binding.ReaderQuotas.MaxArrayLength = int.MaxValue; 
binding.ReaderQuotas.MaxDepth = int.MaxValue; 
binding.ReaderQuotas.MaxBytesPerRead = int.MaxValue; 
binding.ReaderQuotas.MaxNameTableCharCount = int.MaxValue; 
TimeSpan timeoutSpan = DateTime.Now.AddMinutes(30) - DateTime.Now; 
binding.CloseTimeout = timeoutSpan; 
binding.OpenTimeout = timeoutSpan; 
binding.ReceiveTimeout = timeoutSpan; 
binding.SendTimeout = timeoutSpan; 
binding.ReliableSession.InactivityTimeout = timeoutSpan; 
binding.MaxBufferPoolSize = int.MaxValue; 

//we set the security type 
binding.Security.Mode = SecurityMode.Message; 
binding.Security.Message.ClientCredentialType = MessageCredentialType.UserName; 
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; 


ChannelFactory<TService> channelFactory = new ChannelFactory<TService>(binding, remoteAddress); 

_service = channelFactory.CreateChannel(); 

유의하시기 바랍니다 난을 제거하는 것이 여기에

연결을 만드는 내 코드의 일부이다 내 사용자 정의 인증과 관련된 부분이 더 깨끗한 코드

답변

4

고객이 Windows 도메인 외부에서 보안을 원하지만 고객이 인증서를 원합니다. 인증서가 없습니다 = 보안이 없습니다. 이것이 고객에게 설명해야하는 사항입니다.

서버에 개인 키가있는 인증서가 있어야하며 클라이언트는 해당 인증서를 신뢰해야합니다 (게시자를 신뢰하는 경우 설치하지 않아도됩니다). 무슨 뜻이에요? 당신은 세 가지 옵션이

  • 신뢰할 수있는 게시자의 인증서를 구입해야하며, 고객이 단순히
  • 당신의 고객이 자신의 인증 기관이 인증서를 생성하고 클라이언트가 기관의 인증서가 있어야하는 설치되어 있어야 작동합니다 고객 신뢰할 수있는 루트 기관 저장소 (모든 큰 회사에는 자체 인증 기관이 있음)에 있습니다.
  • 프로덕션에서 자체 서명 된 인증서를 사용합니다. 이것은 "안전성이 떨어지며"권장하지 않습니다. 보안 수준이 낮 으면 클라이언트가 자체 서명 된 인증서를 신뢰해야하고 인증서 체인의 유효성을 검사 할 수 없음 = 신뢰할 수있는 기관에서 발급 한 인증서의 유효성을 검사 할 수 없으며 해당 인증 기관에서 손상된 인증서의 유효성을 검사 할 수 없습니다. 이 시나리오에서는 각 클라이언트에 서비스 인증서를 설치해야합니다. 이는 자체 서명 인증서를 신뢰하는 유일한 방법입니다 (설치 자체는 실제로 신뢰입니다).

보안이 작동하는 방식입니다. 자신 만의 것을 만들 수 있습니다.하지만 실제로는 보안을 강화하기 위해 비대칭 암호화가 적용된 PKI (개인 키 인프라)가 필요합니다. 인증서는 주로 공개 키와 개인 키의 포장, 저장 및 전송에 관한 것입니다.

+0

좋아요, 제가 생각한 것입니다.고객이 암호화를 원하지 않고 인증서를 설치/지불 할 필요가 없다면 어떻게해야합니까? (권장 할 해결책은 아니지만 알 필요가 있습니다) 그리고 : 인증서를 구입하면 무엇을해야합니까? 내가 여기서 확인 할까? 일부 인증서는 http만으로 작동한다고 가정합니다. – J4N

+0

SSL 서버 인증서가 작동합니다. 자신 만의 맞춤 솔루션을 만들고 싶다면 그것은 당신에게 달려 있습니다. 전달하기 전에 메시지 내용을 암호화하고 메시지 내용을받은 후에 해독해야합니다. 아마도 사용자 지정 메시지 관리자 나 사용자 지정 채널/인코더가이를 수행합니다. 암호화를 위해 안전하게 키를 저장하는 방법을 찾아야합니다 (이것은 정확히 어떤 인증서가 무엇입니까). –

+0

고맙습니다. 고객 네트워크에서만 서버에 액세스 할 수 있다면 어떻습니까? 내 말은, 신뢰할 수있는 게시자의 경우? 내부 네트워크 이름 또는 개인 IP에 대해 적법한 SSL 인증서를 얻을 수 있습니까? – J4N

관련 문제