2

Asp.Net 3.5 を実行している Win2003 R2 サーバーで Azure ACS を WIF と共に使用しています。Azure ACS がサイトにリダイレクトされると、次の例外が発生します。

Exception information: 
    Exception type: CryptographicException
    Exception message: The system cannot find the file specified.

at System.Security.Cryptography.ProtectedData.Protect(Byte[] userData, Byte[] optionalEntropy, DataProtectionScope scope) 
   at Microsoft.IdentityModel.Web.ProtectedDataCookieTransform.Encode(Byte[] value)

調査によると、IIS 6 で Web サイトを実行している AppPool ID は、関連する暗号化キーにアクセスできない可能性がありますが、回避策は見つかりませんでした。

4

2 に答える 2

0

解決策は別の投稿によるものであることが判明しました。Windows 2003 R2 のアプリケーション プールと同じアカウントで実行される単純な Windows サービスを作成する必要がありました。

于 2012-05-02T12:21:30.527 に答える
0

サイトで使用されている SSL 証明書を使用してセッション Cookie を暗号化し、IIS アプリケーション プールを実行するユーザーにその証明書の秘密キーへのアクセスを許可することをお勧めします。

前者は次の方法で実現できます。

まず、Application Start イベントで、onServiceConfigurationCreated イベントをフックします。

void Application_Start(object sender, EventArgs e)
{
    // Code that runs on application startup
    FederatedAuthentication.ServiceConfigurationCreated += OnServiceConfigurationCreated;

}

次に、次の実装を使用します。

void OnServiceConfigurationCreated(object sender, ServiceConfigurationCreatedEventArgs e)
{
    //
    // Use the <serviceCertificate> to protect the cookies that are
    // sent to the client.
    //
    if (e.ServiceConfiguration.ServiceCertificate != null)
    {
        List<CookieTransform> sessionTransforms =
            new List<CookieTransform>(new CookieTransform[] {
                new DeflateCookieTransform(), 
                new RsaEncryptionCookieTransform(e.ServiceConfiguration.ServiceCertificate),
                new RsaSignatureCookieTransform(e.ServiceConfiguration.ServiceCertificate)  });
        SessionSecurityTokenHandler sessionHandler = 
            new SessionSecurityTokenHandler(sessionTransforms.AsReadOnly());
        e.ServiceConfiguration.SecurityTokenHandlers.AddOrReplace(sessionHandler);
    }

microsoft.identityModel セクション内の Certificates セクションにその証明書を追加する必要があります。

  <serviceCertificate>
    <certificateReference x509FindType="FindByThumbprint" findValue="[cert_thumbprint]" />
  </serviceCertificate>

最後に、その証明書の秘密鍵へのアクセスをアプリケーション プールを実行するユーザーに許可するには、次を使用します。

winhttpcertcfg -g -a "AppPool アカウント" -c LOCAL_MACHINE\My -s www.mysite.com

ここで、winhttpcertcfgはここからダウンロードするツールです。LOCAL_MACHINE\Myは証明書ストアの名前で、SSL 証明書が配置されています。" www.mysite.com " は、SSL 証明書のサブジェクト (CN) 名です。

これで問題が解決すると思います。そうでない場合は、結果とともにここに戻ってきてください。

于 2012-05-01T19:50:34.960 に答える