[rabbitmq-discuss] Security Exception in IIS using RabbitMQ Client

Dave Seltzer dseltzer at tveyes.com
Fri Jul 20 19:43:17 BST 2012


Thanks for your help Tim,

It seems like this isn't an issue with actual file IO, but rather Code
Security.

I've tried setting <trust level="Full" originUrl="" /> in the web.config,
but it doesn't seem to help.

The full stacktrace is below.

-D

[SecurityException: Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +54
   System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase)
+162
   System.Reflection.Assembly.GetName(Boolean copiedName) +117
   RabbitMQ.Client.Impl.ConnectionBase.DefaultClientProperties() +42
   RabbitMQ.Client.ConnectionFactory..ctor() +70
   ASP.api_messagesearch_aspx.__Render__control1(HtmlTextWriter __w,
Control parameterContainer) in \\[snip]\api\MessageSearch.aspx:9
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer,
ICollection children) +115
   System.Web.UI.Page.Render(HtmlTextWriter writer) +38
   System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+11070247
   System.Web.UI.Page.ProcessRequest(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
+11069786
   System.Web.UI.Page.ProcessRequest() +91
   System.Web.UI.Page.ProcessRequest(HttpContext context) +240
   ASP.api_messagesearch_aspx.ProcessRequest(HttpContext context) in
c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET
Files\root\cb973a2c\79ccea1e\App_Web_nkfbtca4.9.cs:0

System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionS
tep.Execute() +599
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
completedSynchronously) +171

-----Original Message-----
From: rabbitmq-discuss-bounces at lists.rabbitmq.com
[mailto:rabbitmq-discuss-bounces at lists.rabbitmq.com] On Behalf Of Tim
Watson
Sent: Friday, July 20, 2012 2:33 PM
To: Discussions about RabbitMQ
Cc: Discussions about RabbitMQ
Subject: Re: [rabbitmq-discuss] Security Exception in IIS using RabbitMQ
Client


http://stackoverflow.com/questions/4925331/system-security-permissions-fil
eiopermission-when-accessing-folder-outside-web-s


On 20 Jul 2012, at 19:28, Tim Watson <watson.timothy at gmail.com> wrote:

>
> On 20 Jul 2012, at 19:06, Dave Seltzer <dseltzer at tveyes.com> wrote:
>
>> I'm having a bit of trouble using the .NET RabbitMQ client in IIS,
maybe
>> someone knows what I'm running into.
>>
>> Here's the code I'm trying to run:
>>
>>   ConnectionFactory rabbitConFactory = new ConnectionFactory();
>>   rabbitConFactory.Address = "hostname";
>>   rabbitConFactory.VirtualHost = "/path";
>>   rabbitConFactory.UserName = "user";
>>   rabbitConFactory.Password = "password";
>>
>>   IConnection connection = rabbitConFactory.CreateConnection();
>>
>>   IModel channel = connection.CreateModel();
>>
>>   Dictionary<String, Object> args = new Dictionary<string, object>();
>>   args.Add("x-ha-policy", "all");
>>   String ExchangeName = "SearchInstructions";
>>   channel.ExchangeDeclare(ExchangeName, "topic", true, false, args);
>>
>>   Guid myId = new Guid();
>>   String RoutingKey = myId.ToString() + ".Instruction";
>>   IBasicProperties MessageProperties = channel.CreateBasicProperties();
>>   MessageProperties.SetPersistent(true);
>>   MessageProperties.ContentEncoding = "UTF-8";
>>   MessageProperties.ContentType = "text/xml";
>>   MessageProperties.Headers.Add("x-origin",
>> Request.ServerVariables["ServerName"]);
>>
>>   String messageContent = "<foo />";
>>   byte[] data = System.Text.Encoding.UTF8.GetBytes(messageContent);
>>   channel.BasicPublish(ExchangeName,RoutingKey, MessageProperties,
>> data);
>>
>>   channel.Close();
>>   connection.Close();
>>
>> When I run the code in an ASPX page I receive the following Security
>> Exception:
>>   Security Exception
>>
>>   Description: The application attempted to perform an operation not
>> allowed by the security policy.  To grant this application the required
>> permission please contact your system administrator or change the
>> application's trust level in the configuration file.
>>
>>   Exception Details: System.Security.SecurityException: Request for the
>> permission of type 'System.Security.Permissions.FileIOPermission,
>> mscorlib, Version=2.0.0.0, Culture=neutral,
>> PublicKeyToken=b77a5c561934e089' failed.
>>
>> I'm not really sure how to proceed. This sounds like an IIS issue, but
>> someone here must have tackled this problem before.
>>
>
> This is indeed an IIS configuration issue. You need to grant the
assembly the appropriate code access permissions. It's been a long time
since I looked at IIS, so I can't tell you exactly where to set this up
until I'm in front of a browser, but checking msdn for Code Access,
FileIOPermission, assemblies and IIS is where I'd start if you want to get
a head start. Post the list if you figure it out first please! :)
>
>> Thanks much!
>>
>> -Dave
>> _______________________________________________
>> rabbitmq-discuss mailing list
>> rabbitmq-discuss at lists.rabbitmq.com
>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
_______________________________________________
rabbitmq-discuss mailing list
rabbitmq-discuss at lists.rabbitmq.com
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss


More information about the rabbitmq-discuss mailing list