以下に示すように暗号化されたいくつかの接続文字列があるコンソールアプリケーションがあります。
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>soemvalue here</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>some valye here</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
次のようなコンソールアプリケーションを使用して、接続文字列にアクセスしようとしています。
var connectionString = ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString;
次のエラーが発生します。
プロバイダー'RsaProtectedConfigurationProvider'を使用した復号化に失敗しました。プロバイダーからのエラーメッセージ:RSAキーコンテナを開くことができませんでした。
復号化せずにapp.configから同じ接続文字列にアクセスしようとすると、正常に機能します。暗号化に問題はありますか?暗号化後、通常の方法で接続文字列をフェッチするだけで、自動的に復号化されると思いました。