2015-09-02 2 views
0

При выполнении приложения-потребителя оно дает мне следующее исключение: Запрошенная услуга 'https://localhost:53996/HistoricStatementsWS.HistoricStatements.svc' не может быть активирована.Потребление услуги WCF с самоподписанным сертификатом

и когда я пытаюсь ввести этот путь в хром, он говорит: Регистрация уже существует для URI 'https://ws20.intra.local:53996/HistoricStatementsWS.HistoricStatements.svc'.

Я не знаю, как избавиться от этих исключений, и до сих пор я прошел через множество форумов.

Серверный app.config

<system.web> 
<compilation debug="true" /> 
<membership defaultProvider="ClientAuthenticationMembershipProvider"> 
    <providers> 
    <add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" /> 
    </providers> 
</membership> 
<roleManager defaultProvider="ClientRoleProvider" enabled="true"> 
    <providers> 
    <add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" /> 
    </providers> 
</roleManager> 
</system.web> 
<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpEndpointBinding"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Certificate" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<services> 
    <service behaviorConfiguration="behaviourHttps" name="HistoricStatementsWS.HistoricStatements"> 
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" 
     name="wsHttpEndpoint" contract="HistoricStatementsWS.IHistoricStatements" /> 
    <endpoint address="HistoricStatementsWS.HistoricStatements.svc" 
     binding="wsHttpBinding" bindingConfiguration="wsHttpEndpointBinding" 
     name="mexEndpoint" contract="IMetadataExchange" /> 
    <host> 
     <baseAddresses> 
     <add baseAddress="https://localhost:53996/" /> 
     </baseAddresses> 
    </host> 
    </service> 
</services> 
<behaviors> 
    <serviceBehaviors> 
    <behavior name="behaviourHttps"> 
     <useRequestHeadersForMetadataAddress /> 
     <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" 
     httpsGetUrl="https://localhost:53996/HistoricStatementsWS.HistoricStatements.svc" 
     policyVersion="Policy15" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
</system.serviceModel> 
</configuration> 

КЛИЕНТ-SIDE WebConfig

<configuration> 
<configSections> 
</configSections> 
<system.web> 
<compilation debug="true" targetFramework="4.5" /> 
<httpRuntime targetFramework="4.5" /> 
</system.web> 
<system.webServer> 
<directoryBrowse enabled="true" showFlags="Date,Time,Extension,Size" /> 
</system.webServer> 
<system.serviceModel> 
<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpEndpoint"> 
     <security mode="Transport"> 
     <transport clientCredentialType="Certificate" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 
</bindings> 
<client> 
    <endpoint behaviorConfiguration="endpointBehavior" address="https://localhost:53996/HistoricStatementsWS.HistoricStatements.svc" binding="wsHttpBinding" 
    bindingConfiguration="wsHttpEndpoint" contract="IHistoricStatements.IHistoricStatements" 
    name="wsHttpEndpoint" /> 
</client> 
<behaviors> 
    <endpointBehaviors> 
    <behavior name="endpointBehavior"> 
     <clientCredentials> 
     <clientCertificate storeLocation="LocalMachine" storeName="My" findValue="00B192126A72D282D2" x509FindType="FindBySerialNumber"/> 
     <serviceCertificate> 
      <authentication certificateValidationMode="None" revocationMode="NoCheck" /> 
     </serviceCertificate> 
     </clientCredentials> 
    </behavior> 
    </endpointBehaviors> 
</behaviors> 
</system.serviceModel> 
</configuration> 

ответ

0

Для тех, кто с такой же проблемой мне удалось решить проблему, направляя свой IP-адрес 127.0.0.1 в моей полной области name: computername.intra.local. Я изменил localhost в веб-конфигурации сервера на свое доменное имя (computername.intra.local) и удалил префикс домена из httpsGetUrl, так как baseAddress также используется для этого значения, поэтому https://localhost:53996/ был дублирован. Хотя все еще есть повторяющиеся значения, и конфигурация по-прежнему неточна, по крайней мере wsdl доступен из браузера. Браузер (на моем локальном компьютере) запрашивает сертификат и успешно проходит проверку подлинности.

Однако мне все еще не хватает знаний о достижении одного и того же URL-адреса с другой машины в той же сети. Я установил корневые и клиентские сертификаты, поскольку они находятся на моем локальном компьютере, и все же он дает эту ошибку: «HTTP-запрос был запрещен с помощью схемы проверки подлинности клиента« Анонимный ». У меня была эта ошибка на моем локальном компьютере с клиентской стороны, но она была разрешена, вызывая сертификат программно. Тот же код на новой машине не работает.

Код:

WSHttpBinding httpBinding = new WSHttpBinding(SecurityMode.Transport); 
httpBinding.Security.Transport.ClientCredentialType =  HttpClientCredentialType.Certificate; 
httpBinding.Security.Message.NegotiateServiceCredential = false; 
httpBinding.Security.Message.EstablishSecurityContext = false; 

var httpUri = new Uri("https://ws12.intra.local:53996/HistoricStatementsWS.Historicstatements.svc"); 
var httpEndpoint = new EndpointAddress(httpUri, EndpointIdentity.CreateDnsIdentity("")); 
var newFactory = new ChannelFactory<IHistoricStatements>(httpBinding, httpEndpoint); 
newFactory.Credentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName, "ws12.intra.local"); 
newFactory.Credentials.ServiceCertificate.SetDefaultCertificate(StoreLocation.LocalMachine, StoreName.My, X509FindType.FindBySubjectName, "ws12.intra.local"); 

Я должен добавить, что никакие прокси не используются, «Anonymous» включен в IIS с пользователем IUSR, корневая папка имеет полный permissios к IUSR, IIS_IUSRS, сети, сетевой службы , Я первый хочу подключиться из браузера на новой машине, так как это дает ошибку:

403 -Forbidden: Access is denied. You do not have permission to view this directory or page using the credentials that you supplied.

Ваши ответы очень ценятся.

Justin