Клиент подключается к сервису по сертификату. Но возникает ошибка "Не удается активировать запрошенную службу... Дополнительные сведения см. в журналах диагностического отслеживания сервера". Ошибка возникает только у одного клиента, на тестовом стенде не воспроизводится. В Event Viewer сообщений не нашли.
Что может вызвать ошибку?
Конфиг клиента:
XML |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
| <?xml version="1.0"?>
<configuration>
<appSettings>
<add key="clientCertificateStoreLocation" value="CurrentUser" />
<add key="clientCertificateStoreName" value="My" />
</appSettings>
<system.net>
<defaultProxy useDefaultCredentials="true"/>
</system.net>
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="wsHttpCertificateBinding" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
maxBufferPoolSize="52428800" maxReceivedMessageSize="52428800" >
<readerQuotas maxStringContentLength="2147483647" />
<security>
<message clientCredentialType="Certificate" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://test:8090/PersonalApi/PersonalApiService.svc/ByCertificate"
binding="wsHttpBinding" bindingConfiguration="wsHttpCertificateBinding"
contract="PersonalApiService.IPersonalApiService" name="wsHttpCertificateEndpoint">
<identity>
<certificateReference findValue="c1 72 dc 82 0c 5d df 2d 92 c1" x509FindType="FindByThumbprint"
storeLocation="CurrentUser" storeName="Root" />
</identity>
</endpoint>
</client>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
</startup>
</configuration> |
|
Конфиг сервиса:
XML |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
| <?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<binding name="wsHttpCertificateBinding">
<security>
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate" negotiateServiceCredential="false" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="PersonalApiServiceBehavior" name="Service.Web.Api.PersonalApi.PersonalApiService">
<endpoint address="ByCertificate" binding="wsHttpBinding" bindingConfiguration="wsHttpCertificateBinding"
name="wsHttpCertificateEndpoint" contract="Service.Web.Api.PersonalApi.IPersonalApiService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior>
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
<behavior name="PersonalApiServiceBehavior">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
<serviceCredentials>
<serviceCertificate findValue="c1 72 dc 82 0c 5d df 2d 92 c1" storeLocation="LocalMachine" x509FindType="FindBySerialNumber"/>
<clientCertificate>
<authentication certificateValidationMode="Custom"
customCertificateValidatorType="Service.Web.Api.CustomValidators.CustomCertificateValidator, Service.Web.Api"/>
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
</system.serviceModel>
</configuration> |
|
Добавлено через 3 минуты
Контракт:
C# |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| namespace Service.Web.Api.PersonalApi
{
using System;
using System.Collections.Generic;
using System.Net.Security;
using System.ServiceModel;
[ServiceContract(Namespace = "http://Service/Web/Api/PersonalApi",
ProtectionLevel = ProtectionLevel.EncryptAndSign)]
public interface IPersonalApiService
{
[OperationContract]
void TestAuthentication();
}
} |
|
Добавлено через 4 минуты
Реализация:
C# |
1
2
3
4
5
6
7
8
9
10
11
| namespace Service.Web.Api.PersonalApi
{
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class PersonalApiService : IPersonalApiService
{
public void TestAuthentication()
{
// Если метод выполнился, значит пользователь успешно аутентифицирован
}
}
} |
|
Добавлено через 3 часа 55 минут
Разобрался. Админы искали сообщение об ошибке не там, где их просили
Причина ошибки была в недостаточных правах доступа пользователя, под которым выполнялся сервис, к контейнеру закрытого ключа. Во время тестирования выяснил, что аналогичная ошибка возникает, если сервис не может найти нужный сертификат.