单声道错误,无效的IL Code System.ServiceModel.Security.Tokens.BinarySecretSecurityToken方法主体为空

时间:2016-01-13 23:10:43

标签: c# apache asp.net-mvc-5 mono ubuntu-14.04

我试图在ubuntu 14.04上使用apache + mod_mono部署一个asp .net mvc 5应用程序并且我得到这个错误:System.ServiceModel.Security.Tokens.BinarySecretSecurityToken中无效的IL代码:.ctor(byte []):方法身体是空的。这是堆栈跟踪:

at Microsoft.Owin.Security.Jwt.SymmetricKeyIssuerSecurityTokenProvider..ctor (System.String issuer, IEnumerable`1 keys) <0x4165f510 + 0x00157> in <filename unknown>:0 
at Microsoft.Owin.Security.Jwt.SymmetricKeyIssuerSecurityTokenProvider..ctor (System.String issuer, System.Byte[] key) <0x4165f4a0 + 0x00053> in <filename unknown>:0
at myapplication.Startup.ConfigureOAuthTokenConsumption (IAppBuilder app) <0x4165e9f0 + 0x00193> in <filename unknown>:0
at myapplication.WebUI.Startup.Configuration (IAppBuilder app) <0x416308d0 + 0x0005f> in <filename unknown>:0 
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) 
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x40b97ec0 + 0x000b7> in <filename unknown>:0

这是我的启动类的代码:

    private void ConfigureOAuthTokenGeneration(IAppBuilder app)
    {
        // Configure the db context and user manager to use a single instance per request
        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);

        OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
        {
            //For Dev enviroment only (on production should be AllowInsecureHttp = false)
            AllowInsecureHttp = true,
            TokenEndpointPath = new PathString("/oauth/token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
            Provider = new CustomOAuthProvider(),
            AccessTokenFormat = new CustomJwtFormat("http://localhost:80/")
        };

        // OAuth 2.0 Bearer Access Token Generation
        app.UseOAuthAuthorizationServer(OAuthServerOptions);
    }

    private void ConfigureOAuthTokenConsumption(IAppBuilder app) {

        var issuer = "http://localhost:80/";
        string audienceId = ConfigurationManager.AppSettings["as:AudienceId"];
        byte[] audienceSecret = TextEncodings.Base64Url.Decode(ConfigurationManager.AppSettings["as:AudienceSecret"]);

        // Api controllers with an [Authorize] attribute will be validated with JWT
        app.UseJwtBearerAuthentication(
            new JwtBearerAuthenticationOptions
            {
                AuthenticationMode = AuthenticationMode.Active,
                AllowedAudiences = new[] { audienceId },
                IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[]
                {
                    new SymmetricKeyIssuerSecurityTokenProvider(issuer, audienceSecret)
                }
            });
    }

有谁知道如何修复此错误?

0 个答案:

没有答案