2009-04-25 4 views
4

I crypté la AppSettings partie de mon web.config, testé sur ma machine et cela a fonctionné, mais quand j'uploadé de l'utiliser en ligne, il m'a donné une erreur:erreur après Encryptingweb.config

Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Failed to decrypt using provider 'DataProtectionConfigurationProvider'. Error message from the provider: Key not valid for use in specified state. (Exception from HRESULT: 0x8009000B)

Line 24: <appSettings configProtectionProvider="DataProtectionConfigurationProvider"> 
Line 25: <EncryptedData> 

J'utilisé les sous pour chiffrer:

Private Sub ProtectSection(ByVal sectionName As String, ByVal provider As String) 
     Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration(Request.ApplicationPath) 

     Dim section As ConfigurationSection = config.GetSection(sectionName) 

     If section IsNot Nothing AndAlso Not section.SectionInformation.IsProtected Then 
      section.SectionInformation.ProtectSection(provider) 
      config.Save() 
     End If 
    End Sub 

Répondre

3

Vous devez publier avec la section déchiffré. La clé utilisée pour crypter/décrypter est spécifique à la machine.

Pour chiffrer les sections de configuration en ligne, appelez la méthode ProtectSection() dans Application_Start() de global.asax.

+1

Vous voulez dire que je dois le chiffrez en ligne? – Maen

+1

Oui, la méthode ProtectSection() que vous utilisez le fera la première fois que l'application sera touchée. – Jeremy

+1

L'a fait, problème résolu ... merci beaucoup ... – Maen

1

Vous devez définir le cryptage .net MachineKey

utilise le MachineKey comme la graine pour le chiffrement/déchiffrement

http://msdn.microsoft.com/en-us/library/w8h3skw9.aspx

Vous devez générer une clé et l'utiliser sur les deux machines. Vous ne pouvez pas utiliser Autogénération non plus.

Plus facile à télécharger simplement et chiffrer non chiffré manuellement sur le serveur si vous le pouvez, sinon vous avez besoin exactement le même MachineKey

Questions connexes