Aspose.Pdf and Medium trust

Hi Tan,


Tilal’s shared the feedback from general perspective and in order to have optimal results, Aspose.Pdf for .NET should be used in Full Trust permission. Nevertheless, starting v9.4.0, we have introduced the support for Medium trust but we are not entirely certain about all the possible scenarios of medium trust where API should work. Please try using our API and in case you encounter any issue, please feel free to contact.

Is it possible to setup Aspose dll in Full Trust in the web config while still have the rest of the site in Medium trust?

Hi Tan,


I am in coordination with our product team for above stated requirement and will get back to you soon.

Has there been any progress with this?


I have tried the following to get the Aspose.PDF to work while keeping the web application in Medium Trust.

I’ve modify the web.config at the “Microsoft.NET\Framework\v4.0.30319\Config” and the web application to include
<add
assemblyName=“Aspose.Pdf”
version=“10.6.0.0”
publicKey=“[deleted]”
/>
<add
assemblyName=“Aspose.Cells”
version=“8.5.1.0”
publicKey=“[deleted]”
/>

I have tried using a custom medium trust configuration with the following lines added:
<IPermission
class=“Aspose.Pdf.Generator.Pdf”
version=“1”
Unrestricted=“true”
Name=“FullTrust”
Description=“Allow full access to Aspose PDF Generator”
/>
and pointing my app web.config to use the custom trust level:

I don’t understand why version 9.6 works under medium trust but was changed in the latest to not work.

Hi Tan,


Thanks for sharing the details and sorry for the delayed response.

I have logged the above stated issue as PDFNEWNET-39261 in our issue tracking system. The product team will further look into the details of this matter and will keep you posted with our findings. We are sorry for this inconvenience.

I have a similar issue in Aspose.Cells that I posted here, I believe the fix is the same for both solution.



Hi Tan,


Thanks for sharing the information. However during our investigation from product team, it appears that Microsoft is not going to solve the Medium trust related issues for ASP.NET and they are going to marks all such issues as Won’t Fix as they are removing Medium Trust support from their framework. For further details, please visit this link.

So as per above description/explanation, the recently reported issue does not seem to be a problem in our API but it appears to be a restriction in recent version of .NET Framework.


Nevertheless, I have shared the link details which you have mentioned with product team and have intimated them to further look into this matter from this perspective.

Hi Tan

Our deployment of Aspose.PDF for .NET requires it to be run on medium trust. If we use the latest standard version, does that mean we should have no problems with medium trust? Or do we need to request a custom DLL to work around the issue?

Thanks

PhilMIntertec:
Hi Tan

Our deployment of Aspose.PDF for .NET requires it to be run on medium trust. If we use the latest standard version, does that mean we should have no problems with medium trust? Or do we need to request a custom DLL to work around the issue?

Thanks
Hi Phil,

Thanks for contacting support.

As shared earlier, the API may work under Medium trust environment however concerning to using the latest release, we are further looking into the details of this requirement and will keep you posted with our findings. We are sorry for this delay and inconvenience.

PhilMIntertec:
Our deployment of Aspose.PDF for .NET requires it to be run on medium trust. If we use the latest standard version, does that mean we should have no problems with medium trust? Or do we need to request a custom DLL to work around the issue?
Hi Phil,

Thanks for your patience.

I have further discussed the scenario with product team and following our observations. The Medium trust was added to our product 2 years ago for .net 2.0. However Microsoft implemented other security systems starting from .net 4.0 and medium trust was marked as deprecated.

The official position of the ASP.NET team is that Medium Trust is obsolete, so it means following actions were taken:

We are automatically marked all Medium Trust-related bugs reported to us as “won’t fix”.
We have provided guidance that everyone needs to migrate away from Medium Trust and use proper OS-level isolation instead (ASP.NET Partial Trust does not guarantee application isolation - Microsoft Support).
We are removing Medium Trust support from the frameworks we developed (MVC, WebAPI, SignalR, and so on) and going forward, applications built on these frameworks will require Full Trust.
In current context, the term “Medium Trust” above refers to all non-Full Trust configurations in ASP.NET, including use of the built-in trust levels (Minimal, Low, Medium, High) or any custom trust levels.

Later on in May 2015, the .NET Framework as a whole was deprecated for partial trust and customers were advised not to rely on it as a security boundary. From MSDN:
Code Access Security in .NET Framework should not be used as a security boundary with partially trusted code, especially code of unknown origin. We advise against loading and executing code of unknown origins without putting alternative security measures in place.

Therefore, it is not recommended to use medium trust. We support medium trust for .net 2.0 but we recommend to get rid of it and use assemblies under .net v. 4.0 and higher. In case you get errors in .net 4.0, we need your code snippet in order to investigate the code and fix the issues.

Should you have any further query, please feel free to contact.

Hi Nayyer

Thank you for your reply. Despite Medium Trust being obsolete, it appears our hosting company still maintains this as a requirement. What are our options? Older DLL? Custom DLL? Other?

Note we run Aspose Cells on the same hosted environment with no problems.

I'm open to all suggestions and would really love to be able to use your aspose.pdf product in the same way we currently use aspose.cells.

Many thanks
Phil

Hi Phil,


Thanks for sharing the details.

I am further discussing these details with development team and will get back to you soon.

Hi Phil,


Thanks for your patience.

I have further discussed the scenario with product team and in current circumstances, you may consider following either approach

  1. Use old version of API (version 9.2) which was tested and worked well under medium trust.
  2. Please try using latest release and in case you encounter any issues, please share the details and we will investigate and fix them.
Hi

I've tried using the older DLL 9.2, but still get this error:

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 failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request failed.]
      .() +0
   .cctor() +8


Here is the assembly info for the older DLL:

Attributes:
<System.Reflection.AssemblyCopyrightAttribute("Copyright 2002-2013 Aspose Pty Ltd"),
System.Reflection.AssemblyTrademarkAttribute(""),
System.Reflection.AssemblyProductAttribute("Aspose.Pdf"),
System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.0", FrameworkDisplayName = ".NET Framework 4"),
System.Reflection.AssemblyCompanyAttribute("Aspose Pty Ltd"),
System.Diagnostics.DebuggableAttribute(2),
System.Runtime.CompilerServices.RuntimeCompatibilityAttribute(WrapNonExceptionThrows = True),
System.Runtime.CompilerServices.CompilationRelaxationsAttribute(8),
System.Reflection.AssemblyInformationalVersionAttribute("2014.04.26"),
System.Reflection.AssemblyTitleAttribute("Aspose.Pdf"),
System.Reflection.AssemblyDescriptionAttribute("A .Net Pdf Component"),
System.Reflection.AssemblyConfigurationAttribute(""),
System.Runtime.InteropServices.ComVisibleAttribute(True),
SmartAssembly.Attributes.PoweredByAttribute("Powered by SmartAssembly 5.5.0.153"),
System.Runtime.CompilerServices.SuppressIldasmAttribute,
System.Reflection.AssemblyFileVersionAttribute("5.5.0.153")>

Hi Phil,


Thanks for sharing the details.

We are further look into the details of this information and will get back to you soon.
Hi Nayyer

Thank you for your prompt response. I'm doing a little more investigation at my end. I'll hopefully get back to you with more detailed information soon.

Many thanks
Phil

Hi Phil,


Thanks for contacting support.

Please take your time and note that we already have tested Aspose.Pdf for .NET 9.2 in trusted environment and it worked without any problem. In case the problem still occurs, please share some details on how you have used the API and if possible, please share a sample project, so that we can further investigate the scenario in our environment. We are sorry for this inconvenience.
Thanks again Nayyer

I am now using v9.2 and I'm getting the following error.

Cannot find license 'Aspose.Pdf.lic'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileNotFoundException: Cannot find license 'Aspose.Pdf.lic'.

Is there anything unusual about the way v9.2 handles license files?

Kind regards
Phil

Hi Phil,


Thanks for sharing the details.

There has been no change related to license initialization in recent release versions. However concerning to above error message, ensure that license file is preset and has same name as specified in code snippet and also ensure that your application has access to location containing license file.

In case the issue still occurs, can you please share if the same issue occurred when tested the latest release versions. We are sorry for this inconvenience.
Hi

I tried version 9.2.1 (instead of 9.2.0) and now get this error:

Server Error in '/' Application.

Cannot find black listed licenses resource. Please report this error to Aspose.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: Cannot find black listed licenses resource. Please report this error to Aspose.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Cannot find black listed licenses resource. Please report this error to Aspose.]
   š..e() +527
   š..˜(Stream ) +156
   š..˜(String , Assembly ) +133
   Aspose.Pdf.License.SetLicense(String licenseName) +86
   TimeProWebApp.GeneratePDF.Page_Load(Object sender, EventArgs e) +787
   System.Web.UI.Control.OnLoad(EventArgs e) +92
   System.Web.UI.Control.LoadRecursive() +54
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.36366

Does this provide any clues?

Regards
Phil