IdentityServer / IdentityServer2

[deprecated] Thinktecture IdentityServer is a light-weight security token service built with .NET 4.5, MVC 4, Web API and WCF.
Other
409 stars 291 forks source link

Bad key on SHA256 self signed certificate #779

Closed Prom001 closed 10 years ago

Prom001 commented 10 years ago

Hi, I have a working SAML1.0 Federation. Now I replace with a new certificate since it needs a SHA256 thumbprint. I generate certificate with: [code] makecert -a sha256 -n cn=mycompany:dev.sso.mycompany.nl -ss my -pe -len 4096 -sk mycompany:dev.sso.mycompany.nl -sr localmachine -r [/code] The STS does its work, but on the Client part I get next error. Can it be that something is wrong with thumbprint ? I replaced it everywhere. [code] [CryptographicException: Bad Key. ] System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) +33 System.Security.Cryptography.RSACryptoServiceProvider.EncryptKey(SafeKeyHandle pKeyContext, Byte[] pbKey, Int32 cbKey, Boolean fOAEP, ObjectHandleOnStack ohRetEncryptedKey) +0 System.Security.Cryptography.RSACryptoServiceProvider.Encrypt(Byte[] rgb, Boolean fOAEP) +57 System.IdentityModel.RsaEncryptionCookieTransform.Encode(Byte[] value) +476 System.IdentityModel.Tokens.SessionSecurityTokenHandler.ApplyTransforms(Byte[] cookie, Boolean outbound) +57 System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(XmlWriter writer, SecurityToken token) +655 System.IdentityModel.Tokens.SessionSecurityTokenHandler.WriteToken(SessionSecurityToken sessionToken) +85 System.IdentityModel.Services.SessionAuthenticationModule.WriteSessionTokenToCookie(SessionSecurityToken sessionToken) +520 System.IdentityModel.Services.SessionAuthenticationModule.AuthenticateSessionSecurityToken(SessionSecurityToken sessionToken, Boolean writeCookie) +103 System.IdentityModel.Services.WSFederationAuthenticationModule.SetPrincipalAndWriteSessionToken(SessionSecurityToken sessionToken, Boolean isSession) +366 System.IdentityModel.Services.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequestBase request) +1470 System.IdentityModel.Services.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args) +464 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69 [/code]

Prom001 commented 10 years ago

Fixed, added Exchange: makecert -a sha256 -n "cn=mycompany:dev.sso.mycompany.nl" -ss my -pe -len 4096 -sr localmachine -r -sky exchange