Ciao a tutti
Sto facendo delle prove con WCF per avere un accesso sicuro ai miei servizi.
Sto provando ad usare la autenticazione di tipo Username: per fare ciò ho configurato il server in questo modo
Il behavior:
<behaviors>
<serviceBehaviors>
<behavior name="CustomerWebServiceBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="false" />
<serviceCredentials>
<clientCertificate>
<certificate findValue="ServerGestionale" storeLocation="CurrentUser"
storeName="My" x509FindType="FindBySubjectName" />
</clientCertificate>
<serviceCertificate findValue="ServerGestionale" storeLocation="CurrentUser"
x509FindType="FindBySubjectName" />
<userNameAuthentication userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="Techsol.Gestionale.Services.UserValidator, Techsol.Gestionale.Services" />
</serviceCredentials>
</behavior>
</serviceBehaviors>
</behaviors>
Il binding:
<bindings>
<wsHttpBinding>
<binding name="UserNameBinding" maxReceivedMessageSize="524288">
<security>
<transport clientCredentialType="Certificate" />
<message clientCredentialType="UserName" />
</security>
</binding>
</wsHttpBinding>
</bindings>
I certificati che uso li ho creati con makecert e tramite mmc uno lo ho inserito nella trusted root certification authority, mentre l'altro l'ho aggiunto alla cartella personal.
Quando provo ad utilizzare il servizio da un client, impostando username e password da codice, viene generata una eccezione SecurityNegotiationException con questo messaggio:
The X.509 certificate CN=ServerGestionale is not in the trusted people store. The X.509 certificate CN=ServerGestionale chain building failed. The certificate that was used has a trust chain that cannot be verified. Replace the certificate or change the certificateValidationMode. The revocation function was unable to check revocation for the certificate.
Il client è configurato in questo modo:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="ClientCredentialsBehavior">
<clientCredentials>
<clientCertificate findValue="ServerGestionale" storeName="TrustedPeople"
x509FindType="FindBySubjectName" />
<serviceCertificate>
<authentication certificateValidationMode="PeerOrChainTrust" />
</serviceCertificate>
</clientCredentials>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="HTTPWebService" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" bypassProxyOnLocal="false"
transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="524288"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Certificate" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" negotiateServiceCredential="true"
algorithmSuite="Default" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8731/Design_Time_Addresses/Techsol.Gestionale.WebServices/CostumerWebService/"
behaviorConfiguration="ClientCredentialsBehavior" binding="wsHttpBinding"
bindingConfiguration="HTTPWebService" contract="CustomerServiceReference.ICustomerServices"
name="HTTPWebService">
<identity>
<dns value="localhost" />
<certificateReference storeName="TrustedPeople" storeLocation="CurrentUser"
x509FindType="FindBySubjectName" findValue="ServerGestionale" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Alcuni storeName sono valorizzati a TrustedPeople anzichè My perchè ho fatto alcune prove googlando qua e la, ma non mi hanno portato a nessun risultato. Il mio certificato oltre che in personale è stato aggiunto anche a trusted people.
Qualcuno di voi sa come potrei risolvere questo problema.
Grazie mille per il supporto.
Ciao
Matteo