2011-10-19 40 views
8

この問題は私たちのサービスにアクセスしているすべてのクライアントで発生しませんが、一貫しているのは、エラーが発生したときにいくつかのクライアントに同じサービスコールを提供します。ここで取得403禁止されたエラーです。クライアント認証スキーム「Anonymous」でHTTPリクエストが禁止されました

は、例外の詳細は以下のとおりです。例外は、クライアントによってスローされている

System.ServiceModel.Security.MessageSecurityException The HTTP request was forbidden with client authentication scheme 'Anonymous'. System.ServiceModel.Security.MessageSecurityException: The HTTP request was forbidden with client authentication scheme 'Anonymous'. > ---> System.Net.WebException: The remote server returned an error: (403) Forbidden. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Security.IssuanceTokenProviderBase 1.DoNegotiation(TimeSpan timeout) at System.ServiceModel.Security.SspiNegotiationTokenProvider.OnOpen(TimeSpan timeout) at System.ServiceModel.Security.TlsnegoTokenProvider.OnOpen(TimeSpan timeout) at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.CommunicationObjectSecurityTokenProvider.Open(TimeSpan timeout) at System.ServiceModel.Security.SecurityUtils.OpenTokenProviderIfRequired(SecurityTokenProvider tokenProvider, TimeSpan timeout) at System.ServiceModel.Security.SymmetricSecurityProtocol.OnOpen(TimeSpan timeout) at System.ServiceModel.Security.WrapperSecurityCommunicationObject.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.SecurityChannelFactory 1.ClientSecurityChannel 1.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.DoOperation(SecuritySessionOperation operation, EndpointAddress target, Uri via, SecurityToken currentToken, TimeSpan timeout) at System.ServiceModel.Security.SecuritySessionSecurityTokenProvider.GetTokenCore(TimeSpan timeout) at System.IdentityModel.Selectors.SecurityTokenProvider.GetToken(TimeSpan timeout) at System.ServiceModel.Security.SecuritySessionClientSettings 1.ClientSecuritySessionChannel.OnOpen(TimeSpan timeout) at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade) at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at > Proxy.FileTransferService.IFileTransferService.EstablishProxy(DownloadRequest request) at Proxy.FileTransferService.FileTransferServiceClient. Proxy.FileTransferService.IFileTransferService.EstablishProxy(DownloadRequest request) at NormalFileTransferServiceClient.Download(Int32 packageId, IStreamWriter downloader, Archiver archiver) at LoggingFileTransferServiceClient.Download(Int32 packageId, ISt

。 IFileTransferServiceため

クライアントプロキシの設定は次のとおりです。(私はすべてを正しく設定している場合)、いくつかのクライアントがbasicHttpBindingを使用している:

<binding name="WSHttpBinding_IFileTransferService" 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="65536" messageEncoding="Mtom" 
    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="Windows" proxyCredentialType="None" 
     realm="" /> 
    <message clientCredentialType="UserName" negotiateServiceCredential="true" 
     algorithmSuite="Default" establishSecurityContext="true" /> 
    </security> 
</binding> 

    <endpoint address="http://[hostname]/FileTransferService.svc/FileTransfer" 
    binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IFileTransferService" 
    contract="Proxy.FileTransferService.IFileTransferService" 
    name="WSHttpBinding_IFileTransferService"> 
    <identity> 
     <certificate encodedValue="a long string"/> 
    </identity> 
    </endpoint> 

サービス構成は

<service behaviorConfiguration="ServiceBehavior" 
    name="Services.FileTransferService"> 
     <endpoint name="WSHttpBinding_IFileTransferService" 
     binding="wsHttpBinding" 
     bindingConfiguration="MtomWSHttpBinding" 
     contract="Services.IFileTransferService" 
     address="/FileTransfer"/> 
     <endpoint binding="basicHttpBinding" 
     bindingConfiguration="FileTransferServicesBinding" 
     contract="Services.IFileTransferService"/> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://[hostname]/FileTransferService.svc"/> 
      </baseAddresses> 
     </host> 
</service> 

<binding name="wsHttpBinding" 
     maxReceivedMessageSize="2147483647" 
     receiveTimeout="5" 
     useDefaultWebProxy="false"> 
     <readerQuotas maxDepth="2147483647" 
      maxStringContentLength="2147483647" 
      maxArrayLength="2147483647" 
      maxBytesPerRead="2147483647" 
      maxNameTableCharCount="2147483647" /> 
    <security mode="Message"> 
    <message clientCredentialType="UserName" /> 
    </security> 
</binding> 

<basicHttpBinding> 
    <binding name="FileTransferServicesBinding" 
      maxReceivedMessageSize="10067108864" 
      messageEncoding="Mtom" 
      transferMode="Streamed" 
      useDefaultWebProxy="false"> 
     <security mode="None"> 
     <message clientCredentialType="UserName" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 

注意です。クライアントの最新リリースでは、完全に分散されていない可能性があります(2つのバージョンをサポートする必要があります)ので、代わりにwsHttpBindingエンドポイントを使用するようにプロキシを変更しました。私は、このエラーがbasicHttpに固有であるかどうか、もしそうなら、これらの設定が正しく設定されていないかどうか疑問に思っています。私は、この403エラーを受け取っているクライアントがwsHttpBindingを使用していると仮定しています。ここで

がサービスのためのコードです:何かwithing私のコントロールがこの例外を取り除く場合

public RemoteBinaryInfo EstablishProxy(DownloadRequest request) 
{ 
    int packageId = request.PackageId; 

    System.IO.MemoryStream stream = new System.IO.MemoryStream(packageRepository.GetPackageBinary(packageId)); 

    DisposeStreamWhenOperationIsComplete(stream, OperationContext.Current); 

    RemoteBinaryInfo result = new RemoteBinaryInfo(); 
    result.Length = stream.Length; 
    result.MemoryByteStream = stream; 
    return result; 

} 

private static void DisposeStreamWhenOperationIsComplete(System.IO.MemoryStream stream, OperationContext clientContext) 
{ 
    clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) 
    { 
     if (stream != null) 
      stream.Dispose(); 
    }); 
} 

は、いずれかが知っていますか?クライアントまたはサービスの設定ファイルのいずれかで設定を変更できますか?

私からの情報が必要な場合は、お知らせください。

+0

まだ完了していない場合は、単純なhello worldメソッドを公開して問題を切り分けてください。 – JoeBilly

答えて

0

MessageSecurityExceptionを受信して​​いるクライアントが、リクエストに有効なユーザー名とパスワードを入力していないように聞こえます。

だから、あなたが匿名認証を使用してIISで構成されたWebサービスを持っている、とあなたは、ユーザーのほんの一握りのための403の禁止エラーが出るhttp://msdn.microsoft.com/en-us/library/ms733131.aspx

+0

上記の処理が行われている場合、呼び出し元のドメインでエラーを受信して​​いるクライアント間に接続がありますか? また、エラーを受け取っているクライアントがプロキシを介して要求を送信していないことを除外すると便利です。 それ以外の場合は、クライアントとサービスの両方でメッセージトレースを有効にしてください。http://msdn.microsoft.com/en-us/library/ms730064.aspx –

+0

ユーザー名とパスワードは、それは解読される。クライアントとこれらのサービスとの間に人間の相互作用はありません。私が生成したプロキシはアプリケーションとともに配布され、自動的に実行されます。 – SideFX

+0

私はすでにこのcreds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrustを持っています。これにより問題が解決する可能性があります:creds.ServiceCertificate.Authentication.TrustedStoreLocation = StoreLocation.LocalMachine;私が得ているエラーは、すべてのクライアント要求に対して起こっているわけではありませんが、特定のクライアントネットワーク構成では、上記のコードを追加する必要があります。明示的にクライアントのサーバー証明書の場所を示す目的は何ですか? – SideFX

0

次のMSDNトピックを参照してください。

これは通常、ファイルシステムなどのACL制御システムリソースにアクセスするときに、アクセス拒否例外が原因で発生します。

通常、アプリケーションプールID(IIS APPPOOL/AppPoolName)を持つw3wp.exeプロセスによって、異常に接続されたすべてのユーザーは要求が処理されます(IIS 7と仮定します)。そのIDが必要なアクセス制御リストアクセス拒否例外により、IISは403エラーで応答します。

通常、アプリケーションプールIDをグループに追加してから、必要なリソースにグループを追加します。

例外の原因となっているリソースを特定できない場合は、セキュリティイベントログで、手がかりの「監査失敗」エントリを調べてみてください。セキュリティイベントをログに記録するようにローカルセキュリティポリシーを構成する必要があります。私の場合は

幸運

3

このエラーは、私たちの組織のHTTPプロキシサーバからでした。 MessageSecurityException.InnerException.Response.Headers

{マイム・バージョン:1.0
X-イカ-エラー:ERR_ACCESS_DENIED 0
X-キャッシュ:<
X-キャッシュルックアップからのMISS:NONE < proxy-からからそれを見つけましたサーバアドレス>
プロキシ接続:近い
のContent-Length:2165
のContent-Type:text/htmlの
日:水曜日、2012年4月25日10時55分39秒GMT
サーバー:イカ/ 3.0.STABLE25
経由:1.0 <プロキシサーバアドレス>(イカ/ 3.0.STABLE25)
}

私の場合も、それがファイルを転送したファイル転送方法のために発生しましたサイズが16384のbyte配列内のチャンク。サイズを10000に縮小すると、エラーは解決されました。つまり、プロキシサーバーには何らかのサイズ制限が設定されています。インターネットへの直接アクセスを持つマシンで

は、ファイル転送方法であっても、配列の大きさのために、このエラーで失敗したことはありません> 16384

あなたのクライアントのいくつかは、この問題に直面しているだけので、おそらく彼らはファイアウォールの背後にあります/実際にアクセスをブロックしてこのエラーを返すプロキシサーバーですか?

+0

同じです。プロキシサーバーをバイパスしてローカルアドレスを確認するのを忘れた – AlexDev

関連する問題