如何在 DotNetOpenAuth 上添加我的声明
如何使用 DotNetOpenAuth 作为 OpenID 提供程序将我自己的声明添加到用户断言中?
我需要向 ClaimsRequest 和 ClaimsResponse 添加一些属性,例如“UserID”。我在 ClaimsRequest.cs 和 ClaimsResponse.cs 类中添加了此属性,当我使用此更改构建 DotNetOpenAuth 时,它在 VS 2010 中运行良好,但当我在 iis 7.5 上发布时,它会抛出此异常:
“/OpenID”应用程序中的服务器错误。
无法加载文件或程序集 “DotNetOpenAuth.Contracts”或其中之一 它的依赖项。强名 签名无法验证。这 组件可能已被篡改, 或者延迟签署但未完全签署 使用正确的私钥签名。 (HRESULT 异常:0x80131045) 描述:未处理的异常 执行期间发生的 当前的网络请求。请查看 堆栈跟踪以获取有关的更多信息 错误及其起源 代码。
异常详细信息: System.IO.FileLoadException:无法 加载文件或程序集 “DotNetOpenAuth.Contracts”或其中之一 它的依赖项。强名 签名无法验证。这 组件可能已被篡改, 或者延迟签署但未完全签署 使用正确的私钥签名。 (HRESULT 异常:0x80131045)
来源错误:
生成了未处理的异常 当前执行期间 网络请求。有关信息 异常的起源和地点 可以使用异常来识别 下面的堆栈跟踪。
程序集加载跟踪:以下内容 信息可以帮助 确定装配原因 “DotNetOpenAuth.Contracts”无法 已加载。
WRN:程序集绑定日志记录是 关闭。启用程序集绑定 失败记录,设置注册表 价值 [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) 到 1。 注意:有一些 与相关的性能损失 程序集绑定失败日志记录。转动 关闭此功能,删除注册表 价值 [HKLM\Software\Microsoft\Fusion!EnableLog]。
堆栈跟踪:
[FileLoadException:无法加载 文件或程序集 “DotNetOpenAuth.Contracts”或其中之一 它的依赖项。强名 签名无法验证。这 组件可能已被篡改, 或者延迟签署但未完全签署 使用正确的私钥签名。 (HRESULT 异常:0x80131045)]
[FileLoadException:无法加载 文件或程序集 'DotNetOpenAuth.合同, 版本=3.4.6.11075,文化=中立, PublicKeyToken=2780ccd10d57b246' 或 它的依赖项之一。强名 签名无法验证。这 组件可能已被篡改, 或者延迟签署但未完全签署 使用正确的私钥签名。 (HRESULT 异常:0x80131045)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName 文件名、字符串代码库、证据 程序集安全性、运行时程序集 locationHint、StackCrawlMark& 堆栈标记,布尔值 throwOnFileNotFound,布尔值 用于自省,布尔值 抑制安全检查)+0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName 装配参考、证据 assemblySecurity、StackCrawlMark& stackMark,用于自省的布尔值, 布尔抑制安全检查)+567
System.Reflection.RuntimeAssembly.InternalLoad(字符串 汇编字符串,证据 assemblySecurity、StackCrawlMark& stackMark,用于自省的布尔值) +192 System.Reflection.Assembly.Load(字符串 汇编字符串)+35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 程序集名称,布尔星指令) +118[配置错误异常:可以 不加载文件或程序集 'DotNetOpenAuth.合同, 版本=3.4.6.11075,文化=中立, PublicKeyToken=2780ccd10d57b246' 或 它的依赖项之一。强名 签名无法验证。这 组件可能已被篡改, 或者延迟签署但未完全签署 使用正确的私钥签名。 (HRESULT 异常:0x80131045)] System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串 程序集名称,布尔星指令) +11396867 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +484 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +127 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig)+334
System.Web.Compilation.BuildManager.CallPreStartInitMethods() +280 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost, IConfigMapPathFactory 配置MapPathFactory, 托管环境参数 托管参数、策略级别 政策级别、例外 appDomainCreationException)+1087[HttpException (0x80004005):无法 加载文件或程序集 'DotNetOpenAuth.合同, 版本=3.4.6.11075,文化=中立, PublicKeyToken=2780ccd10d57b246' 或 它的依赖项之一。强名 签名无法验证。这 组件可能已被篡改, 或者延迟签署但未完全签署 使用正确的私钥签名。 (HRESULT 异常:0x80131045)] System.Web.HttpRuntime.FirstRequestInit(HttpContext 上下文)+11529072
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext 上下文)+141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr,HttpContext 上下文)+4784373------------------------------------------------------------ --------------------------------- 版本信息:Microsoft .NET 框架版本:4.0.30319;网络平台 版本:4.0.30319.1
How can I add my own claim to a user assertion using DotNetOpenAuth as an OpenID Provider?
I need to add some attribute to ClaimsRequest and ClaimsResponse like "UserID". I added this attribute in both class ClaimsRequest.cs and ClaimsResponse.cs, and when I build DotNetOpenAuth with this change, it works well in VS 2010 but when I publish on iis 7.5 it throws this exception:
Server Error in '/OpenID' Application.
Could not load file or assembly
'DotNetOpenAuth.Contracts' or one of
its dependencies. Strong name
signature could not be verified. The
assembly may have been tampered with,
or it was delay signed but not fully
signed with the correct private key.
(Exception from HRESULT: 0x80131045)
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.FileLoadException: Could not
load file or assembly
'DotNetOpenAuth.Contracts' or one of
its dependencies. Strong name
signature could not be verified. The
assembly may have been tampered with,
or it was delay signed but not fully
signed with the correct private key.
(Exception from HRESULT: 0x80131045)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.Assembly Load Trace: The following
information can be helpful to
determine why the assembly
'DotNetOpenAuth.Contracts' could not
be loaded.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].Stack Trace:
[FileLoadException: Could not load
file or assembly
'DotNetOpenAuth.Contracts' or one of
its dependencies. Strong name
signature could not be verified. The
assembly may have been tampered with,
or it was delay signed but not fully
signed with the correct private key.
(Exception from HRESULT: 0x80131045)][FileLoadException: Could not load
file or assembly
'DotNetOpenAuth.Contracts,
Version=3.4.6.11075, Culture=neutral,
PublicKeyToken=2780ccd10d57b246' or
one of its dependencies. Strong name
signature could not be verified. The
assembly may have been tampered with,
or it was delay signed but not fully
signed with the correct private key.
(Exception from HRESULT: 0x80131045)]
System.Reflection.RuntimeAssembly._nLoad(AssemblyName
fileName, String codeBase, Evidence
assemblySecurity, RuntimeAssembly
locationHint, StackCrawlMark&
stackMark, Boolean
throwOnFileNotFound, Boolean
forIntrospection, Boolean
suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName
assemblyRef, Evidence
assemblySecurity, StackCrawlMark&
stackMark, Boolean forIntrospection,
Boolean suppressSecurityChecks) +567
System.Reflection.RuntimeAssembly.InternalLoad(String
assemblyString, Evidence
assemblySecurity, StackCrawlMark&
stackMark, Boolean forIntrospection)
+192 System.Reflection.Assembly.Load(String
assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
assemblyName, Boolean starDirective)
+118[ConfigurationErrorsException: Could
not load file or assembly
'DotNetOpenAuth.Contracts,
Version=3.4.6.11075, Culture=neutral,
PublicKeyToken=2780ccd10d57b246' or
one of its dependencies. Strong name
signature could not be verified. The
assembly may have been tampered with,
or it was delay signed but not fully
signed with the correct private key.
(Exception from HRESULT: 0x80131045)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String
assemblyName, Boolean starDirective)
+11396867 System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()
+484 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal()
+127 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection
compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods()
+280 System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager
appManager, IApplicationHost appHost,
IConfigMapPathFactory
configMapPathFactory,
HostingEnvironmentParameters
hostingParameters, PolicyLevel
policyLevel, Exception
appDomainCreationException) +1087[HttpException (0x80004005): Could not
load file or assembly
'DotNetOpenAuth.Contracts,
Version=3.4.6.11075, Culture=neutral,
PublicKeyToken=2780ccd10d57b246' or
one of its dependencies. Strong name
signature could not be verified. The
assembly may have been tampered with,
or it was delay signed but not fully
signed with the correct private key.
(Exception from HRESULT: 0x80131045)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext
context) +11529072
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext
context) +141
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest
wr, HttpContext context) +4784373-------------------------------------------------------------------------------- Version Information: Microsoft .NET
Framework Version:4.0.30319; ASP.NET
Version:4.0.30319.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不应向
ClaimsRequest
或ClaimsResponse
类添加属性,因为它们是简单注册扩展,并且具有一组固定的属性。相反,您应该使用属性交换扩展,它允许您设置和检索其上的任意属性(声明),而无需重新编译库。在 DotNetOpenAuth 中,这意味着使用
FetchRequest
和FetchResponse
类来承载您的自定义声明。您从 IIS 收到的错误是因为您没有正确地“签署”DotNetOpenAuth 版本。但如果您遵循这些说明,您不需要自己构建它,因此我将放弃有关如何正确构建的说明。
You should not be adding attributes to the
ClaimsRequest
orClaimsResponse
classes as that is the Simple Registration extension and has a fixed set of attributes on it.Instead, you should use the Attribute Exchange extension, which allows you to set and retrieve arbitrary properties (claims) on it without recompiling the library. In DotNetOpenAuth this means to use the
FetchRequest
andFetchResponse
classes to carry your custom claims.The error you're getting from IIS is because you've improperly "signed" your build of DotNetOpenAuth. But you shouldn't need to build it yourself if you follow these instructions, so I'll forego the instructions for how to build properly.