2012-02-16 9 views
5

こんにちは、WebRoleとしてWindows AzureプロジェクトでホストされているWCFサービスを作成しました。WCFセキュリティバインディングの問題

私のサービスはSSL証明書で保護されています。これは動作します。
私は運用契約にいくつかのセキュリティを追加したいと思います。これを行うと(保護レベルを設定すると)次のエラーが表示されます。

私はこの作業をするために何らかのバインディングや他のものを設定する必要がありますが、私は何がわかりませんし、どこにわからないのですか。

プロジェクト情報:

エラー:

The request message must be protected. This is required by an operation of the contract ('IService1','http://tempuri.org/'). 
    The protection must be provided by the binding ('BasicHttpBinding','http://tempuri.org/'). 

アーキテクチャ

enter image description here
ServiceConfiguration.Cloud.cscfg & ServiceConfiguration.Local.cscfg

<?xml version="1.0" encoding="utf-8"?> 
<ServiceConfiguration serviceName="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*"> 
    <Role name="WCFServiceWebRole"> 
    <Instances count="1" /> 
    <ConfigurationSettings> 
     <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" /> 
    </ConfigurationSettings> 
    <Certificates> 
     <Certificate name="Certificate1" thumbprint="51F357715F" thumbprintAlgorithm="sha1" /> 
    </Certificates> 
    </Role> 
</ServiceConfiguration> 

ServiceDefinition.csdef

<?xml version="1.0" encoding="utf-8"?> 
<ServiceDefinition name="Azure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"> 
    <WebRole name="WCFServiceWebRole" vmsize="ExtraSmall" enableNativeCodeExecution="true"> 
    <Sites> 
     <Site name="Web"> 
     <Bindings> 
      <Binding name="Endpoint1" endpointName="Endpoint1" /> 
      <Binding name="Endpoint2" endpointName="Endpoint2" /> 
     </Bindings> 
     </Site> 
    </Sites> 
    <Endpoints> 
     <InputEndpoint name="Endpoint1" protocol="http" port="80" /> 
     <InputEndpoint name="Endpoint2" protocol="https" port="8080" certificate="Certificate1" /> 
    </Endpoints> 
    <Imports> 
     <Import moduleName="Diagnostics" /> 
    </Imports> 
    <LocalResources> 
     <LocalStorage name="WCFServiceWebRole.svclog" sizeInMB="1000" cleanOnRoleRecycle="false" /> 
    </LocalResources> 
    <Certificates> 
     <Certificate name="Certificate1" storeLocation="LocalMachine" storeName="My" /> 
    </Certificates> 
    </WebRole> 
</ServiceDefinition> 

契約

[DataContract] 
public class KlantenContract 
{ 
    [DataMember] 
    public int PARTYID { get; set; } 

    [DataMember] 
    public string firstName { get; set; } 

    [DataMember] 
    public string lastName { get; set; } 

IService1.cs

namespace WCFServiceWebRole 
{ 
    [ServiceContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)] 
    public interface IService1 
    { 
     [OperationContract(ProtectionLevel = ProtectionLevel.EncryptAndSign)] 
     List<KlantenContract> GetAllKlanten(string firstName); 
    } 
} 

のWeb.config

<system.serviceModel> 

    <bindings> 
     <wsHttpBinding> 
     <binding name="IService1"> 
      <security mode="Transport"></security> 
     </binding> 
     <binding name="Certificate1"> 
      <security> 
      <message clientCredentialType="Certificate"/> 
      </security> 
     </binding> 
     </wsHttpBinding> 
    </bindings> 

    <services> 
     <service name="Service1" behaviorConfiguration="ServiceBehavior"> 
     <endpoint address="https://127.0.0.1:8080/Service1.svc" binding="wsHttpBinding" 
      name="Endpoint2" contract="IService1"> 
     </endpoint> 
     </service> 
    </services> 

    <behaviors> 
     <serviceBehaviors> 

      <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
      <serviceCredentials> 
       <serviceCertificate findValue="CN=tempCert" /> 
      </serviceCredentials> 
      </behavior> 

      <behavior> 
      <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
      <serviceMetadata httpGetEnabled="true" /> 
      <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 

答えて

3

あなたがEncryptAndSignとしてあなたのサービスを設定した場合、それはたとえばHTTPSのために、安全な交通機関を使用する必要があります。最後のスクリーンショットでは、HTTPまたはHTTPS経由でサービスを表示した場合はわかりませんが、HTTPSを使用する必要があります。

保護されたバインディングがIISで処理されるようにするには、セキュリティモードをTransportWithCredentialOnlyに設定して、自分の証明書を使用して443にバインドするWebロールを設定しますそれはOKであるはずです。

トランスポートセキュリティを使用することもできますし、ServerCredential部分では、WCFでセキュリティ保護されたトランスポートの作成に使用する証明書を指定する必要があります。

私はメッセージセキュリティモードを試したことはありませんが、動作するはずですが、メッセージセキュリティ構成要素の下で証明書も指定する必要があるかもしれません。

+0

いいえ私はまだ同じ欠陥がありますが、私は自分のアーキテクチャや構成に間違っていると思いますか?私の構造 - >最後のスクリーンショットが見えますか?私はweb.configまたはAzureプロジェクトの設定でバインディングを設定する必要がありますか? – dg90

+0

web.configにあります。私は時間があるときに見て、あなたに戻ってきます。 –

+0

ありがとう、私はたくさんのものを結んだが、彼は私の構成を取っていないか、またはそれを間違って設定しているように常に同じエラーを投げつけ続けます..; – dg90