【问题标题】:Unable to download from HTTPS site using Assembly.LoadFrom无法使用 Assembly.LoadFrom 从 HTTPS 站点下载
【发布时间】:2009-04-27 14:54:19
【问题描述】:

无法在 Assembly.LoadFrom 中使用 HTTPS 路径。

也尝试使用TrustAllCertificatePolicy 类,但没有成功。

我已经从客户端机器上完全信任使用 caspol 的服务器。相同的 URL 可在禁用 ssl 的情况下使用。它不适用于启用 ssl。请帮忙。

例外是:

System.IO.FileLoadException: Security problem encountered when connecting to URL for 'https://ip/tasks/tasks.dll'. File name: 'https://ip/tasks/tasks.dll'    
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity,
     Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)    
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, 
    StackCrawlMark& stackMark, Boolean forIntrospection)    
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, 
    Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)    
at System.Reflection.Assembly.LoadFrom(String assemblyFile, Evidence securityEvidence)    
    WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value 
    [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated 
    with assembly bind failure logging. To turn this feature off, remove the registry value 
    [HKLM\Software\Microsoft\Fusion!EnableLog]. 

【问题讨论】:

  • 能否设置 HKLM\Software\Microsoft\Fusion!EnableLog 以获得更好的异常日志?

标签: c# assemblies


【解决方案1】:

代码访问安全将阻止来自 http 和 https 位置的代码执行正常(完全权限访问)。

您将需要创建一个新的 AppDomain(可能还有可远程/可序列化的类型以跨越应用程序域边界),并在 AppDomain 中使用 CAS 设置以使用 Internet 权限集运行。这样可以避免下载的代码修改本地机器。

如果您真的信任远程代码(以及能够或将能够修改它的每个人),您当然可以创建自定义权限集以允许更多访问。

【讨论】:

    猜你喜欢
    • 2012-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-21
    • 1970-01-01
    • 2022-06-13
    • 2017-08-27
    相关资源
    最近更新 更多