Encryption Error

D

Dave Bailey

I have developed a web app using DPAPI to encrypt a
connection string in the web.config file. The application
works perfectly on the development machine but when
deployed to the server when opening the app the following
wrror is generated:

Exception decrypting. Decryption failed. Key not valid for
use in specified state.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.

Exception Details: System.Exception: Exception decrypting.
Decryption failed. Key not valid for use in specified
state.

Source Error:

An unhandled exception was generated during the execution
of the current web request. Information regarding the
origin and location of the exception can be identified
using the exception stack trace below.

Stack Trace:


[Exception: Exception decrypting. Decryption failed. Key
not valid for use in specified state.
]
DataProtection.DataProtector.Decrypt(Byte[] cipherText,
Byte[] optionalEntropy)
StatusTrack.welcomeForm.GetConnectionString() +130
StatusTrack.welcomeForm.CreateDataSource() +19
StatusTrack.welcomeForm.FillGrid() +665
StatusTrack.welcomeForm.Page_Load(Object sender,
EventArgs e) +170
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731


Does anyone have an answer for this?

Thanks,

Dave
 
P

Peter Rilling

DPAPI uses the currently logged in user as the key for the encryption. Your
development machine most likely uses a different user account then your
server, therefore the decryption key is different.

How did you encrypt the information? Did you encrypt it on your development
machine and then just copy the web.config to the server? You will probably
need to encrypt the content on the machine you are deploying it to.
 
D

Dave Bailey

I figured the problem out. The encryption was using the
machine store so it needed to be encrypted on the server.
Thanks for the input,

Dave
-----Original Message-----
I did indeed encrypt the information on the development
machine and then deployed the app to the server. My
question now is how can I use it on the server as that is
where the app must run?

Thanks,

Dave

-----Original Message-----
DPAPI uses the currently logged in user as the key for the encryption. Your
development machine most likely uses a different user account then your
server, therefore the decryption key is different.

How did you encrypt the information? Did you encrypt it on your development
machine and then just copy the web.config to the
server?
You will probably
need to encrypt the content on the machine you are deploying it to.


"Dave Bailey" <[email protected]>
wrote
in message
I have developed a web app using DPAPI to encrypt a
connection string in the web.config file. The application
works perfectly on the development machine but when
deployed to the server when opening the app the following
wrror is generated:

Exception decrypting. Decryption failed. Key not valid for
use in specified state.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.

Exception Details: System.Exception: Exception decrypting.
Decryption failed. Key not valid for use in specified
state.

Source Error:

An unhandled exception was generated during the execution
of the current web request. Information regarding the
origin and location of the exception can be identified
using the exception stack trace below.

Stack Trace:


[Exception: Exception decrypting. Decryption failed. Key
not valid for use in specified state.
]
DataProtection.DataProtector.Decrypt(Byte[] cipherText,
Byte[] optionalEntropy)
StatusTrack.welcomeForm.GetConnectionString() +130
StatusTrack.welcomeForm.CreateDataSource() +19
StatusTrack.welcomeForm.FillGrid() +665
StatusTrack.welcomeForm.Page_Load(Object sender,
EventArgs e) +170
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +731


Does anyone have an answer for this?

Thanks,

Dave


.
.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top