2010-11-03 4 views
1

J'ai créé un simple service WCF que je souhaite accessible via https. Le service WCF utilise un UserNamePasswordValidator, customBinding et UserNameOverTransport comme mode d'authentification. Je l'ai exécuté dans IIS7.5 où j'ai créé un certificat de serveur auto-signé. Je tente de me connecter à ce service avec une application Silverlight 4. Je crée une référence de service dans mon application Silverlight 4 et VS 2010 crée automatiquement le code nécessaire (il est donc évident qu'il peut se connecter au service et obtenir les informations). Lorsque j'appelle le WCF, j'obtiens une SecurityException sans aucune information sur la raison.SecurityError lors de l'appel d'un service HTTPS-WCF à partir de Silverlight 4

J'ai un fiddler qui court pour voir ce qui se passe.

GET https://my.server:8099/clientaccesspolicy.xml 404 Not Found (text/html)
GET https://my.server:8099/crossdomain.xml 200 OK (text/xml)

Ainsi l'EEG pour le crossdomain.xml semble être le dernier appel au serveur .

Le crossdomain.xml se présente comme suit:

<?xml version="1.0"?> 
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd"> 
<cross-domain-policy> 
    <allow-access-from domain="*" /> 
    <allow-http-request-headers-from domain="*" headers="*" /> 
</cross-domain-policy> 

L'exception se produit, quand base.EndInvoke (...) est appelée sur le client et le ExceptionMessage est le suivant:

{Système .Security.SecurityException ---> System.Security.SecurityException: Sicherheitsfehler bei System.Net.Browser.BrowserHttpWebRequest.InternalEndGetResponse (IAsyncResult asyncResult) bei System.Net.Browser.BrowserHttpWebRequest. <> c_ DisplayClass5.b _4 (Object sendState) bei System.Net.Browser.AsyncHelper. <> c_ DisplayClass2.b _0 (Object sendState) --- Ende der internen Ausnahmestapelüberwachung --- bei System.Net.Browser.AsyncHelper.BeginOnUI (SendOrPostCallback beginMethod, état d'objet) bei System.Net.Browser. BrowserHttpWebRequest.EndGetResponse (IAsyncResult asyncResult) bei System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelAsyncRequest.CompleteGetResponse (résultat IAsyncResult)}

Voici mon UserNamePasswordValidator. Remarque, qui comprenait un enregistreur pour des raisons de débogage. Chose étrange, le logger n'écrit jamais rien, donc il semble que la fonction Validate n'est même pas appelée.

namespace ServiceConfiguratorDataSource 
{ 
    public class UserCredentialsValidator : UserNamePasswordValidator 
    { 
    public override void Validate(string userName, string password) 
    { 
     if (userName != "xyz" || password != "xyz") 
     { 
     logging.Logger.instance.StatusRoutine("LogOn Error: " + userName); 
     throw new FaultException("Credentials are invalid"); 
     } 
     else 
     { 
     logging.Logger.instance.StatusRoutine("LogOn Success: " + userName); 
     } 
    } 
    } 
} 

Voici le web.config de mon WCF-Service:

<?xml version="1.0" encoding="utf-8"?> 
    <configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0" /> 
    </system.web> 
    <system.serviceModel> 
     <services> 
     <service name="ServiceConfiguratorDataSource.Service" behaviorConfiguration="ServiceConfiguratorDataSourceBehaviour"> 
      <endpoint address="" binding="customBinding" bindingConfiguration="ServiceConfiguratorCustomBinding" contract="ServiceConfiguratorDataSource.IService" /> 
     </service> 
     </services> 
     <bindings> 
     <customBinding> 
      <binding name="ServiceConfiguratorCustomBinding"> 
      <security authenticationMode="UserNameOverTransport"></security> 
      <binaryMessageEncoding></binaryMessageEncoding> 
      <httpsTransport/> 
      </binding> 
     </customBinding> 
     </bindings> 
     <behaviors> 
     <serviceBehaviors> 
      <behavior name="ServiceConfiguratorDataSourceBehaviour"> 
      <serviceMetadata httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
      <serviceCredentials> 
       <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="ServiceConfiguratorDataSource.UserCredentialsValidator,ServiceConfiguratorDataSource" /> 
      </serviceCredentials> 
      </behavior> 
     </serviceBehaviors> 
     </behaviors> 
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"/> 
    </system.webServer> 
    </configuration> 

et ici la ServiceReferences.ClientConfig

<configuration> 
    <system.serviceModel> 
    <bindings> 
     <customBinding> 
     <binding name="CustomBinding_IService"> 
      <security authenticationMode="UserNameOverTransport" includeTimestamp="true"> 
      <secureConversationBootstrap /> 
      </security> 
      <binaryMessageEncoding /> 
      <httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" /> 
     </binding> 
     </customBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://my.server:8099/ServiceConfiguratorDataSource/Service.svc" binding="customBinding" bindingConfiguration="CustomBinding_IService" contract="WCFDataProvider.IService" name="CustomBinding_IService" /> 
    </client> 
    </system.serviceModel> 
</configuration> 

Je suis d'idées ce qui pourrait être la cause du problème.

Merci à l'avance,
Frank

Répondre

2

Est-ce que vous clientaccesspolicy.xml permettent https?
Here est un exemple.

+0

Tu es mon héros! Avec le changement à la clientaccesspolicy.xml cela a fonctionné! Le point intéressant, c'est que je devais autoriser http, même si je ne l'utilisais pas sur ma demande, mais avec l'option https, j'ai toujours l'erreur de sécurité! Je vais poster mon clientaccesspolicy.xml fonctionnant ci-dessous, peut-être que quelqu'un d'autre aura le même problème. – Aaginor

1

Le travail clientaccesspolicy.xml -> Tipp de Samvel Siradeghyan

<?xml version="1.0" encoding="utf-8"?> 
    <access-policy> 
    <cross-domain-access> 
     <policy> 
     <allow-from http-request-headers="*"> 
      <domain uri="https://*"/> 
      <domain uri="http://*"/> 
     </allow-from> 
     <grant-to> 
      <resource path="/" include-subpaths="true"/> 
     </grant-to> 
     </policy> 
    </cross-domain-access> 
    </access-policy> 
Questions connexes