This documentation is archived and is not being maintained.

RsaProtectedConfigurationProvider Class

Provides a ProtectedConfigurationProvider instance that uses RSA encryption to encrypt and decrypt configuration data.

Namespace:  System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

[<PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")>]
type RsaProtectedConfigurationProvider =  
        inherit ProtectedConfigurationProvider

The RsaProtectedConfigurationProvider type exposes the following members.

Public methodRsaProtectedConfigurationProviderInitializes a new instance of the RsaProtectedConfigurationProvider class.

Public propertyCspProviderNameGets the name of the Windows cryptography API (crypto API) cryptographic service provider (CSP).
Public propertyDescriptionGets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs). (Inherited from ProviderBase.)
Public propertyKeyContainerNameGets the name of the key container.
Public propertyNameGets the friendly name used to refer to the provider during configuration. (Inherited from ProviderBase.)
Public propertyRsaPublicKeyGets the public key used by the provider.
Public propertyUseMachineContainerGets a value that indicates whether the RsaProtectedConfigurationProvider object is using the machine key container.
Public propertyUseOAEPGets a value that indicates whether the provider is using Optimal Asymmetric Encryption Padding (OAEP) key exchange data.

Public methodAddKeyAdds a key to the RSA key container.
Public methodDecryptDecrypts the XML node passed to it. (Overrides ProtectedConfigurationProvider.Decrypt(XmlNode).)
Public methodDeleteKeyRemoves a key from the RSA key container.
Public methodEncryptEncrypts the XML node passed to it. (Overrides ProtectedConfigurationProvider.Encrypt(XmlNode).)
Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodExportKeyExports an RSA key from the key container.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodImportKeyImports an RSA key into the key container.
Public methodInitializeInitializes the provider with default settings. (Overrides ProviderBase.Initialize(String, NameValueCollection).)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

The RsaProtectedConfigurationProvider class gives you a way to encrypt sensitive information stored in a configuration file, which helps protect it from unauthorized access. You use the built-in RsaProtectedConfigurationProvider instance by declaring the provider and making appropriate settings in the configuration file instead of creating an instance of this class, as shown in the example later in this topic.

The RsaProtectedConfigurationProvider object uses the cryptography functions provided by RSA class to encrypt and decrypt configuration sections.


Before ASP.NET can decrypt encrypted information in your configuration file, the identity of your ASP.NET application must have read access to the encryption key used to encrypt and decrypt the configuration data. For more information, see Walkthrough: Encrypting Configuration Information Using Protected Configuration.

The following code example shows how to use the standard RsaProtectedConfigurationProvider to protect or unprotect a configuration section.

No code example is currently available or this language may not be supported.

The following example shows an excerpt from a configuration file after encryption.

<?xml version="1.0" encoding="utf-8"?>
  <connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
    <EncryptedData Type=""
      <EncryptionMethod Algorithm="" />
      <KeyInfo xmlns="">
        <EncryptedKey xmlns="">
          <EncryptionMethod Algorithm="" />
          <KeyInfo xmlns="">
            <KeyName>Rsa Key</KeyName>

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.