2013-06-12 4 views
1

새 JWT 처리기 라이브러리 (System.IdentityModel.Tokens.Jwt)의 버전 1.0.0을 ACS에서 Azure의 JWT 토큰을 처리하는 ASP.NET MVC 4 응용 프로그램?Azure의 ACS 및 Microsoft의 새로운 System.IdentityModel.Tokens.Jwt 라이브러리와 함께 작동하도록 ASP.NET MVC 4 구성

내 응용 프로그램을 실행하려고 할 때 다음과 같은 오류 메시지가 표시됨 :

[SecurityTokenValidationException : Jwt10329가 : 서명을 검증 할 수 없습니다, Configuration.IssuerTokenResolver.ResolveToken가 널 (null)을 반환했습니다. jwt.Header.SigningKeyIdentifier 'SecurityKeyIdentifier (isReadOnly의 = 거짓, 횟수 = 2 조 [0] = X509ThumbprintKeyIdentifierClause (해시 = 0xXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX) 항 [1] = System.IdentityModel.Tokens.NamedKeySecurityKeyIdentifierClause )'. ] System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateSignature (JwtSecurityToken JWT) 1,275
System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateToken (JwtSecurityToken JWT) +113
System.IdentityModel.Tokens.JwtSecurityTokenHandler.ValidateToken (SecurityToken 토큰) +339
System.IdentityModel.Tokens.SecurityTokenHandlerCollection.ValidateToken (SecurityToken 토큰) +73
System.IdentityModel.Services.TokenReceiver.AuthenticateToken (SecurityToken 토큰, 부울 ensureBearerToken, 문자열 endpointUri) 120
System.IdentityModel.Services.WSFederationAuthenticationModule .SignInWithResponseMessage (HttpRequestBase 요청) 493
System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest (개체 송신자있는 EventArgs 인수) 364
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.Ht tpApplication.ExecuteStep 내 Web.config의이 같은 구성 +69

(IExecutionStep 단계, 부울 & completedSynchronously) :

<system.identityModel> 

    <identityConfiguration> 
     <audienceUris> 
     <add value="http://127.0.0.1:81/" /> 
     </audienceUris> 

     <issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 
     <trustedIssuers> 
        <add thumbprint="PRIVATEKEY" 
        name="https://CUSTOM.accesscontrol.windows.net/" /> 
     </trustedIssuers> 
     </issuerNameRegistry> 

     <securityTokenHandlers> 
     <add type="System.IdentityModel.Tokens.JwtSecurityTokenHandler, System.IdentityModel.Tokens.Jwt" /> 
     <securityTokenHandlerConfiguration> 
      <certificateValidation certificateValidationMode="PeerTrust" /> 
     </securityTokenHandlerConfiguration> 
     <add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     <remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> 
     </securityTokenHandlers> 

    </identityConfiguration> 

    </system.identityModel> 

    <system.identityModel.services> 
    <federationConfiguration> 
     <cookieHandler requireSsl="false" /> 
     <wsFederation passiveRedirectEnabled="false" issuer="https://staging.accesscontrol.windows.net/v2/wsfederation" realm="http://127.0.0.1:81/" requireHttps="false" /> 
    </federationConfiguration> 

    </system.identityModel.services> 

나는 설정 푸른 ACS는 토큰 JWT를 반환하고 올바른를 설정해야 web.config에서 보안 썸네일을 가져 왔지만이 오류가 왜 발생하는지 왜곡되었습니다. 어떤 통찰력?

답변

0

새로운 x.509 인증서를 생성하고이를 Azure ACS에 기본 X.509 인증서로 업로드 한 다음 로컬 컴퓨터의 자격 증명 저장소에 설치하여이 문제를 해결할 수있었습니다.

나는 인증서를 만들려면 다음 지침을 따랐 : 나는 다음 수출

makecert.exe -r -pe -a sha1 -n "CN=YOURNAMESPACE.accesscontrol.windows.net" -ss My -sr CurrentUser -len 2048 -sky exchange -sy 24 

인증서 (자신의 네임 스페이스를 추가해야합니다)를 생성 makecert 명령을 사용 http://blogs.msdn.com/b/cclayton/archive/2012/03/21/windows-azure-and-x509-certificates.aspx

certmgr.mcs를 사용하여 인증서를 PFX 및 CER 파일로 저장합니다.

관리 포털을 사용하여 PFX 파일을 Azure ACS로 가져 왔습니다. 이 블로그 게시물에 설명 된대로이 완료되면 내가 새로운 썸네일을 복사

마지막으로 내 web.config 파일에서 이전 값에 그것을 붙여, 내 인증서 저장소에 CER 파일을 설치 :

http://www.cloudidentity.com/blog/2012/11/20/introducing-the-developer-preview-of-the-json-web-token-handler-for-the-microsoft-net-framework-4-5-2/

위의 블로그 게시물의 텍스트는 다음 텍스트입니다.

.CER. 파일을 두 번 클릭하고 "Install Certificate ..."버튼을 클릭하고 Local Machine, Trusted People을 선택하십시오.

이제 모든 기능이 작동합니다. 희망이 당신을 위해 너무 작동합니다. 더 많은 도움이 필요하면 질문하십시오. 올바른 방향으로 안내해 드리겠습니다.

1

동일한 문제가 발생했습니다. JWT를 사용하면 웹 응용 프로그램은 토큰의 유효성을 검사하기 위해 발급자에 대해 알 필요가 있습니다. X509 인증서가 JWT에 없으므로 인증서 저장소에서 사용할 수 있어야합니다. Vittorio B.는 'WIF 응용 프로그램에서 JWT 처리기 사용하기'섹션에서이 문제를 설명하고 here 단계를 설명합니다.