how can Add My On Claim on DotNetOpenAuth

2

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

openid
dotnetopenauth
asked on Stack Overflow Mar 16, 2011 by user657609 • edited Mar 20, 2011 by Andrew Arnott

1 Answer

3

You should not be adding attributes to the ClaimsRequest or ClaimsResponse 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 and FetchResponse 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.

answered on Stack Overflow Mar 20, 2011 by Andrew Arnott

User contributions licensed under CC BY-SA 3.0