HTTPS를 통해 WCF 서비스를 호출하고 있습니다. => 인증서는 정상입니다. 스크린 샷보기 : 서비스 패브릭에서 HTTPS를 통해 WCF 호출 : 요청이 중단되었습니다. SSL/TLS 보안 채널을 만들 수 없습니다.
클라이언트 인증서가 내 계정 및 로컬 컴퓨터에 설치되어 있습니다. 두 가지 모두 내보낼 수 있습니다.
그래서 콘솔 응용 프로그램에서 작동하는 코드 조각이 있습니다. 네트워크 서비스에서 콘솔 앱을 실행하면 서비스 호출이 작동합니다.
이 코드를 StatefullService (서비스 패브릭 내부)에 붙여 넣으면 다음과 같은 예외가 발생합니다.
콘솔 응용 프로그램 및 서비스 fabcric에서 ServicePointManager.SecurityProtocol
System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11 | System.Net.SecurityProtocolType.Tls12
을 확인했습니다.
"System.ServiceModel.Security.SecurityNegotiationException '. ******** cloudapp.azure.com을'. 권위 SSL/TLS에 대한 보안 채널을 설정할 수 없습니다 ---> System.Net .WebException : 요청이 중단되었습니다 : SSL/TLS 보안 채널을 만들 수 없습니다. System.Net.HttpWebRequest.GetResponse() \ r \ n (System.ServiceModel.Channels.HttpChannelFactory
1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)\r\n --- End of inner exception stack trace ---\r\n\r\nServer stack trace: \r\n at System.ServiceModel.Channels.HttpChannelUtilities.ProcessGetResponseWebException(WebException webException, HttpWebRequest request, HttpAbortReason abortReason)\r\n at System.ServiceModel.Channels.HttpChannelFactory
)에서 1.HttpRequestChannel.HttpChannelRequest. System.ServiceModel.Channels.RequestChannel.Request (메시지 메시지, TimeSpan 시간 초과)에서 \ WaitForReply (TimeSpan 시간 초과) \ r \ n System.ServiceModel.Dispatcher.RequestChannelBinder.Request (메시지 메시지, TimeSpan 시간 초과) System.ServiceModel.Channels.ServiceChannel.Call (String 동작, 부울 oneway, ProxyOperationRuntime 작업, Object [] ins, Object [] 출력, TimeSpan 시간 초과)에서 \ n \ System \ System \ rviceModel.Channels.ServiceChannelProxy.InvokeService (IMethodCallMessage methodCall, ProxyOperationRuntime 작업) \ r \ n System.ServiceModel.Channels.ServiceChannelProxy.Invoke (IMessage 메시지) \ r \ n \ r \ n 예외는 [0]에서 재개됩니다. \ r \ n System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage (IMessage reqMsg, IMessage retMsg) \ System \ Runtime.Remoting.Proxies.RealProxy.PrivateInvoke (MessageData & msgData, Int32 유형)에서 \ r \ n ** ********************************* \ r \ n at ************ **************************************** cs : line 75 \ r \ n at ****************************************** * .cs : 34 행 34 \ r \ n *********************************** . ******** CS : 라인 (20) "
코드는 다음
var binding = new BasicHttpBinding();
binding.Security.Mode = BasicHttpSecurityMode.Transport;
binding.Security.Transport = new HttpTransportSecurity
{
ClientCredentialType = HttpClientCredentialType.Certificate,
};
string endpoint = "https://********.cloudapp.azure.com/*****/SomeService.svc";
var endpoint1 = new EndpointAddress(endpoint);
var factory = new ChannelFactory(binding, endpoint);
var clientCredentials = new ClientCredentials();
clientCredentials.ClientCertificate.SetCertificate("CN=my-cn-name",
System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine,
System.Security.Cryptography.X509Certificates.StoreName.My);
if (factory.Endpoint.EndpointBehaviors.Contains(typeof(ClientCredentials)))
{
factory.Endpoint.EndpointBehaviors.Remove(typeof(ClientCredentials));
}
factory.Endpoint.EndpointBehaviors.Add(clientCredentials);
var channel = factory.CreateChannel();
try
{
var result = channel.GetData(1);
Console.WriteLine("Success");
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e);
Console.ReadLine();
}
서비스 패브릭의 HTTPS를 통해 WCF 서비스를 호출하지 못했습니다. HTTPS 프로토콜을 사용하지 않도록 설정하고 기존 WCF 서비스에서 HTTP 프로토콜을 사용하도록 설정하면 연결할 수 있습니다. 그러나 분명한 이유로 우리는 HTTPS가 필요합니다.
편집 한 테스트
:
이 콘솔 응용 프로그램도 작동하는 HTML을받을 GET으로 HttpClient를하고 WebRequestHandler와 서비스 호출- . 서비스 기능이없는 구조.
- 개인 저장소에서 인증서를 제거했습니다. 콘솔 응용 프로그램은 로컬 컴퓨터 저장소를 사용하기 때문에 계속 작동합니다 (위 코드 샘플 참조).
- HTTPS를 통해 우편 배달부에서 SOAP 요청을 처리합니다.
(네트워크 서비스)이 응답 https://serverfault.com/a/132791/135762 다음 편집 2
작동했다.