O WCF oferece suporte a SNI (indicação de nome de servidor)
-
13-12-2019 - |
Pergunta
Gostaria de consumir um serviço WCF de terceiros usando autenticação básica, mas também preciso usar SNI.Eu hackeei o exemplo a seguir (sem o material real do endpoint) para mostrar o que configurei e o erro que recebo.
Qualquer ajuda será muito apreciada, pois sei pouco sobre WCF e nada sobre SNI.
Configuração
<endpoint
address="https://their.server.com/theirservice.svc"
binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_ISyncFramework2"
contract="ISyncFramework" name="BasicHttpBinding_ISyncFramework2">
</endpoint>
<basicHttpBinding>
<binding name="BasicHttpBinding_ISyncFramework2" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false"
hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="Basic" proxyCredentialType="None"
realm="" />
</security>
</binding>
</basicHttpBinding>
código:
var service = new SyncFrameworkClient();
service.ClientCredentials.UserName.UserName = "username";
service.ClientCredentials.UserName.Password = "thepassword";
service.method() // fails!
a chamada para método falha com:
O serviço solicitado, 'https://their.server.com/theirservice.svc' não pôde ser ativado.Consulte os logs de rastreamento de diagnóstico do servidor para obter mais informações.
O rastreamento do servidor
Server stack trace:
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory factory, WebException responseException, ChannelBinding channelBinding)
at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
Solução
Esse erro geralmente é um problema do lado do serviço e não do lado do cliente.SNI é uma tecnologia de servidor para melhorar o handshake SSL e na pilha da Microsoft está suportado apenas no IIS 8 não lançado versão.A menos que o terceiro implemente sua própria pilha SNI/SSL, parece improvável que seu serviço WCF exija isso.
Na exceção real que você está recebendo, parece que algo como esta postagem do blog provavelmente seria a causa do problema.Sua configuração e trechos de código parecem adequados para basicHttpBinding usando SSL e autenticação HTTP básica.