私の Silverlight/WCF アプリケーションは、各サービス メソッドで PrincipalPermission を使用して、ユーザーが認証されていることを確認します。これは、すべてが HTTP に構成されている場合は問題なく機能しますが、サービス エンドポイント/バインディングを HTTPS (SSL) をサポートするように構成すると、PrincipalPermission オブジェクトの Demand() メソッドを呼び出すと例外がスローされます。
編集: このプロジェクトのホストとデバッグに IIS 7.5 Express を使用していることに言及する必要があります。
ユーザーが認証されていることを確認するメソッドを次に示します。これは、各サービス メソッドから呼び出されます。
protected void SecurityCheck(string roleName, bool authenticated)
{
System.ServiceModel.Web.WebOperationContext.Current.OutgoingResponse.StatusCode = System.Net.HttpStatusCode.OK;
PrincipalPermission p = new PrincipalPermission(null, roleName, authenticated);
try
{
p.Demand();
}
catch (Exception ex)
{
/* wrap the exception so that Silverlight can consume it */
ServiceException fault = new ServiceException()
{
/* Code = 1 will mean "unauthenticated!" */
Code = 1, Message = ex.Message
};
throw new FaultException<ServiceException>(fault); }
}
}
スローされる実行は、「プリンシパルのリクエストが失敗しました」です。
私のweb.configファイルの重要な部分は次のとおりです。
<behavior name="BinarySSL">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<dataContractSerializer maxItemsInObjectGraph="6553600"/>
<serviceTimeouts transactionTimeout="00:10:00"/>
</behavior>
<binding name="MyApp.Web.Services.ProjectService.customBinding0"
receiveTimeout="00:10:00" sendTimeout="00:10:00">
<binaryMessageEncoding />
<httpsTransport authenticationScheme="Basic"/>
</binding>
<service name="MyApp.Web.Services.ProjectService" behaviorConfiguration="BinarySSL">
<endpoint address="" binding="customBinding" bindingConfiguration="MyApp.Web.Services.ProjectService.customBinding0"
contract="MyApp.Web.Services.ProjectService" />
</service>
ClientConfig は次のとおりです。
<binding name="CustomBinding_ProjectService">
<binaryMessageEncoding />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
<endpoint address="https://localhost:44300/Services/ProjectService.svc"
binding="customBinding" bindingConfiguration="CustomBinding_ProjectService"
contract="ProjectProxy.ProjectService" name="CustomBinding_ProjectService" />
誰かがここで正しい方向を示してくれることを願っています。 繰り返しますが、この構成は、サービスを SSL 用に構成するまで問題なく機能します。何かご意見は?
ありがとう、
-スコット
私は問題を見つけたと思って、自分の質問に答えましたが、間違っていました。まだ同じ問題があります。